18719: handle updates on flush()
authorPeter Amstutz <peter.amstutz@curii.com>
Sun, 6 Feb 2022 21:00:33 +0000 (16:00 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Sun, 6 Feb 2022 21:00:33 +0000 (16:00 -0500)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

sdk/python/arvados/collection.py
services/fuse/arvados_fuse/fusedir.py

index 55be40fa04fc0f7a46a5de5a239464547f81df4b..a076de6baf622f560f92859db68e7e8cdafc65f9 100644 (file)
@@ -1395,7 +1395,7 @@ class Collection(RichCollectionBase):
                 # our tokens.
                 return
             else:
-                self._past_versions.add((response.get("modified_at"), response.get("portable_data_hash")))
+                self._remember_api_response(response)
             other = CollectionReader(response["manifest_text"])
         baseline = CollectionReader(self._manifest_text)
         self.apply(baseline.diff(other))
index 704dbe43914826e384e55af12f7fe8a76b95abfd..1f018af81a2e955817f0f48f42c7cf7ea56c5412 100644 (file)
@@ -463,8 +463,12 @@ class CollectionDirectory(CollectionDirectoryBase):
         if not self.writable():
             return
         with llfuse.lock_released:
-            self.collection.save()
-        self.new_collection_record(self.collection.api_response())
+            with self._updating_lock:
+                if self.collection.committed():
+                    self.collection.update()
+                else:
+                    self.collection.save()
+                self.new_collection_record(self.collection.api_response())
 
     def want_event_subscribe(self):
         return (uuid_pattern.match(self.collection_locator) is not None)
@@ -510,7 +514,7 @@ class CollectionDirectory(CollectionDirectoryBase):
                     if not self.stale():
                         return True
 
-                    _logger.debug("Updating collection %s inode %s to record version %s", self.collection_locator, self.inode)
+                    _logger.debug("Updating collection %s inode %s", self.collection_locator, self.inode)
                     coll_reader = None
                     if self.collection is not None:
                         # Already have a collection object
@@ -563,8 +567,8 @@ class CollectionDirectory(CollectionDirectoryBase):
         return False
 
     @use_counter
-    @check_update
     def collection_record(self):
+        self.flush()
         return self.collection.api_response()
 
     @use_counter
@@ -575,6 +579,7 @@ class CollectionDirectory(CollectionDirectoryBase):
                 self.collection_record_file = FuncToJSONFile(
                     self.inode, self.collection_record)
                 self.inodes.add_entry(self.collection_record_file)
+            self.collection_record_file.invalidate()
             return self.collection_record_file
         else:
             return super(CollectionDirectory, self).__getitem__(item)
@@ -662,6 +667,7 @@ class TmpCollectionDirectory(CollectionDirectoryBase):
                 self.collection_record_file = FuncToJSONFile(
                     self.inode, self.collection_record)
                 self.inodes.add_entry(self.collection_record_file)
+            self.collection_record_file.invalidate()
             return self.collection_record_file
         return super(TmpCollectionDirectory, self).__getitem__(item)