]> arthur.barton.de Git - bup.git/commitdiff
vfs: deal with bupm containing no metadata for a file
authorJohannes Berg <johannes@sipsolutions.net>
Sat, 25 Jan 2020 21:20:36 +0000 (22:20 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 23 Feb 2020 20:25:09 +0000 (14:25 -0600)
If a file was for some reason saved without metadata, deal with
this and create an empty/unknown metadata for it instead.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/vfs.py

index 1c8993725c2a1bf0e216810eea1e8e6d89427d6d..ea0b1979c15ab95ea9901b1e59a36c6e03f74718 100644 (file)
@@ -644,9 +644,12 @@ def tree_items(oid, tree_data, names=frozenset(), bupm=None):
             # No metadata here (accessable via '.' inside ent_oid).
             return Item(meta=default_dir_mode, oid=ent_oid)
 
-        return Item(oid=ent_oid,
-                    meta=(Metadata.read(bupm) if bupm \
-                          else _default_mode_for_gitmode(gitmode)))
+        meta = Metadata.read(bupm) if bupm else None
+        # handle the case of metadata being empty/missing in bupm
+        # (or there not being bupm at all)
+        if meta is None:
+            meta = _default_mode_for_gitmode(gitmode)
+        return Item(oid=ent_oid, meta=meta)
 
     assert len(oid) == 20
     if not names: