Merge branch '6451-websockets-invalid-input' closes #6451
[arvados.git] / services / fuse / arvados_fuse / __init__.py
index b24aaa6d3d08c2e470ac3fbb2cb47999e882a53b..c4b9f7e91e88c6a745d433a5f588b18832df6ca5 100644 (file)
@@ -188,6 +188,11 @@ class InodeCache(object):
     def find(self, uuid):
         return self._by_uuid.get(uuid)
 
+    def clear(self):
+        self._entries.clear()
+        self._by_uuid.clear()
+        self._total = 0
+
 class Inodes(object):
     """Manage the set of inodes.  This is the mapping from a numeric id
     to a concrete File or Directory object"""
@@ -244,6 +249,17 @@ class Inodes(object):
     def invalidate_entry(self, inode, name):
         llfuse.invalidate_entry(inode, name)
 
+    def clear(self):
+        self.inode_cache.clear()
+
+        for k,v in self._entries.items():
+            try:
+                v.finalize()
+            except Exception as e:
+                _logger.exception("Error during finalize of inode %i", k)
+
+        self._entries.clear()
+
 
 def catch_exceptions(orig_func):
     """Catch uncaught exceptions and log them consistently."""
@@ -314,12 +330,7 @@ class Operations(llfuse.Operations):
             self.events.close()
             self.events = None
 
-        for k,v in self.inodes.items():
-            try:
-                v.finalize()
-            except Exception as e:
-                _logger.exception("Error during finalize of inode %i", k)
-        self.inodes = None
+        self.inodes.clear()
 
     def access(self, inode, mode, ctx):
         return True