]> arthur.barton.de Git - bup.git/commitdiff
fix unfinished read on tag commits found in vfs cache
authorMuh Muhten <muh.muhten@gmail.com>
Fri, 24 Jun 2022 03:45:41 +0000 (23:45 -0400)
committerRob Browning <rlb@defaultvalue.org>
Sat, 25 Jun 2022 16:36:40 +0000 (11:36 -0500)
tag_item was not reading through repo.cat iterator after grabbing the
item type, leaving an in-progress read when listing tags after a
cached access to the commit referred by the tag.  This manifests as an
AssertionError on `bup ls branch .tag` or similar vfs-consuming
command, or the bup fuse fs becoming almost completely unusable after
this access pattern as it errors EINVAL upon any attempt to read new
data from the repo!  Resolve this by checking the cache up-front
before we do any reading.

Signed-off-by: Muh Muhten <muh.muhten@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/vfs.py

index e68b60cc4e0a42a66e709224f598d1d567bb41b5..541a28f3b4849a8741c1ede4cd0a992731a19b83 100644 (file)
@@ -829,12 +829,14 @@ def tags_items(repo, names):
 
     def tag_item(oid):
         assert len(oid) == 20
+        cached = cache_get_commit_item(oid, need_meta=False)
+        if cached:
+            return cached
         oidx = hexlify(oid)
         it = repo.cat(oidx)
         _, typ, size = next(it)
         if typ == b'commit':
-            return cache_get_commit_item(oid, need_meta=False) \
-                or _commit_item_from_data(oid, b''.join(it))
+            return _commit_item_from_data(oid, b''.join(it))
         for _ in it: pass
         if typ == b'blob':
             return Item(meta=default_file_mode, oid=oid)