From: Muh Muhten Date: Fri, 24 Jun 2022 03:45:41 +0000 (-0400) Subject: fix unfinished read on tag commits found in vfs cache X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=2fcbc19217eef1dd8492c0a4429cc2b22339ec9a fix unfinished read on tag commits found in vfs cache 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 Reviewed-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index e68b60c..541a28f 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -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)