Merge branch '12287-preserve-json-numbers' closes #12287
[arvados.git] / services / fuse / arvados_fuse / fusefile.py
index e731327dec5524432d0eb12c7d9dfc2b900fafd4..585536176007bdfcc889a47647f85114e6a34fb7 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 import json
 import llfuse
 import logging
@@ -29,8 +33,8 @@ class File(FreshBase):
     def mtime(self):
         return self._mtime
 
-    def clear(self, force=False):
-        return True
+    def clear(self):
+        pass
 
     def writable(self):
         return False
@@ -95,6 +99,12 @@ class ObjectFile(StringFile):
         return self.object_uuid
 
     def update(self, obj=None):
+        if obj is None:
+            # TODO: retrieve the current record for self.object_uuid
+            # from the server. For now, at least don't crash when
+            # someone tells us it's a good time to update but doesn't
+            # pass us a fresh obj. See #8345
+            return
         self._mtime = convertTime(obj['modified_at']) if 'modified_at' in obj else 0
         self.contents = json.dumps(obj, indent=4, sort_keys=True) + "\n"
 
@@ -112,12 +122,11 @@ class FuncToJSONFile(StringFile):
         super(FuncToJSONFile, self).__init__(parent_inode, "", 0)
         self.func = func
 
-        # invalidate_inode() and invalidate_entry() are asynchronous
-        # with no callback to wait for. In order to guarantee
-        # userspace programs don't get stale data that was generated
-        # before the last invalidate(), we must disallow dirent
+        # invalidate_inode() is asynchronous with no callback to wait for. In
+        # order to guarantee userspace programs don't get stale data that was
+        # generated before the last invalidate(), we must disallow inode
         # caching entirely.
-        self.allow_dirent_cache = False
+        self.allow_attr_cache = False
 
     def size(self):
         self._update()