From 878bd638c6cedda652ac79c6c8b3a0f14d67966c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 25 Jan 2020 22:20:36 +0100 Subject: [PATCH] vfs: deal with bupm containing no metadata for a file 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 Reviewed-by: Rob Browning (cherry picked from commit da552ea8d19d5da73c0d387d4963bc77841ab9ba) Tested-by: Rob Browning --- lib/bup/vfs.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index 2fa3160..1105f79 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -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: -- 2.39.2