]> 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>
Sat, 25 Apr 2020 19:23:52 +0000 (14:23 -0500)
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>
(cherry picked from commit da552ea8d19d5da73c0d387d4963bc77841ab9ba)
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/vfs.py

index 2fa31608b07b0040cfa0dd2ac6ef30caf4bf0e88..1105f79bd6ff8c0ad62bbbcc2a79ac30ea149cc4 100644 (file)
@@ -637,9 +637,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: