From: Rob Browning Date: Tue, 4 Nov 2014 18:09:37 +0000 (-0600) Subject: save: always push parents when entering a subtree X-Git-Tag: 0.27-rc1~10 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=0eff3fc44bb3dda4c590b9700ad4ab1148084402 save: always push parents when entering a subtree Once we enter the subtree, all of the parents must be on the stack for subsequent operations to work correctly (like the _pop() in the following "if not file:" section). Consider the case where /some/empty/dir was indexed, but removed before save. Without this fix, the metadata read for "dir" would fail and the pending directory stack (parts) would include /some/empty instead of /some/empty/dir. Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/cmd/save-cmd.py b/cmd/save-cmd.py index 93c693b..6cd142f 100755 --- a/cmd/save-cmd.py +++ b/cmd/save-cmd.py @@ -325,8 +325,8 @@ for (transname,ent) in r.filter(extra, wantrecurse=wantrecurse_during): except (OSError, IOError), e: add_error(e) lastskip_name = dir_name - else: - _push(dir_name, meta) + meta = metadata.Metadata() + _push(dir_name, meta) if not file: if len(parts) == 1: diff --git a/t/test-rm-between-index-and-save.sh b/t/test-rm-between-index-and-save.sh index e93dd72..67c5b8a 100755 --- a/t/test-rm-between-index-and-save.sh +++ b/t/test-rm-between-index-and-save.sh @@ -61,15 +61,16 @@ WVPASS rmdir "$D"/foo # with directories, bup notices that foo is missing, so it fails # (complete with delayed error) WVFAIL bup save -n save-fail-missing "$D" -# ... so "foo" is absent from "bup ls" +# ...but foo is still saved since it was just fine in the index WVPASSEQ "$(bup ls -AF save-fail-missing/latest/$TOP/$D/)" "bar/ -baz/" +baz/ +foo/" # Index again: WVPASS bup tick WVPASS bup index -ux "$D" # no non-zero-exitcode anymore: WVPASS bup save -n save-fail-missing "$D" -# foo is (still...) missing, of course: +# foo is now gone WVPASSEQ "$(bup ls -AF save-fail-missing/latest/$TOP/$D/)" "bar/ baz/"