If bup index see that a file foo has no change, bup save still need to read
foo in order to update the metadata. If the user removed foo between the
index and the save, the metadata call metadata.from_path would result in a
non intercepted error. This commit adds a try/except to handle this case.
Signed-off-by: Damien Robert <
Damien.Olivi...@gmail.com>
---
cmd/save-cmd.py | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/cmd/save-cmd.py b/cmd/save-cmd.py
index bd72b76..7afc994 100755
--- a/cmd/save-cmd.py
+++ b/cmd/save-cmd.py
@@ -332,9 +332,18 @@ for (transname,ent) in r.filter(extra, wantrecurse=wantrecurse_during):
shalists[-1].append(git_info)
sort_key = git.shalist_item_sort_key((ent.mode, file, id))
hlink = find_hardlink_target(hlink_db, ent)
- metalists[-1].append((sort_key,
+ # In this case, the index version of the file has not changed since
+ # the last update. We still need to upload the metadata, but this
+ # can fail if the file has been removed after the indexing (or
+ # because we indexed a different subset of files, so in the index
+ # we do not see that the file is missing)
+ try:
+ metalists[-1].append((sort_key,
metadata.from_path(
ent.name,
hardlink_target=hlink)))
+ except (OSError, IOError), e:
+ add_error(e)
+ lastskip_name =
ent.name
else:
if stat.S_ISREG(ent.mode):
try:
@@ -375,9 +384,15 @@ for (transname,ent) in r.filter(extra, wantrecurse=wantrecurse_during):
shalists[-1].append(git_info)
sort_key = git.shalist_item_sort_key((ent.mode, file, id))
hlink = find_hardlink_target(hlink_db, ent)
- metalists[-1].append((sort_key,
+ # an error here is much less probable since we have just read
+ # the file, but there still could be a race condition
+ try:
+ metalists[-1].append((sort_key,
metadata.from_path(
ent.name,
hardlink_target=hlink)))
+ except (OSError, IOError), e:
+ add_error(e)
+ lastskip_name =
ent.name
if exists and wasmissing:
count += oldsize
subcount = 0
--
Patched on top of bup-0.25-rc1-69-gee00d53