Fix a bug in the previous patch:
Include metadata when asked to restore individual non-directory paths.
53649c18ec3db90f80ff4657315009538d4333f3
Don't return whatever metadata you have the first time you hit a
directory in the dir. Wait until you find the right name.
Reported-by: varacanero <varacanero@zeromail.org>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
mfile = dir.metadata_file() # VFS file -- cannot close().
if mfile:
meta_stream = mfile.open()
+ # First entry is for the dir itself.
meta = metadata.Metadata.read(meta_stream)
if name == '':
return meta
for sub in dir:
if stat.S_ISDIR(sub.mode):
- return find_dir_item_metadata_by_name(sub, '')
+ meta = find_dir_item_metadata_by_name(sub, '')
else:
meta = metadata.Metadata.read(meta_stream)
if sub.name == name:
bup() { "$top/bup" "$@"; }
-touch "$tmpdir/foo"
+mkdir "$tmpdir/foo"
+mkdir "$tmpdir/foo/bar" # Make sure a dir sorts before baz (regression test).
+touch "$tmpdir/foo/baz"
WVPASS bup init
WVPASS bup index "$tmpdir/foo"
WVPASS bup save -n foo "$tmpdir/foo"
+# Make sure the timestamps will differ if metadata isn't being restored.
WVPASS bup tick
-WVPASS bup restore -C "$tmpdir/restore" "foo/latest/$tmpdir/foo"
-WVPASS "$top/t/compare-trees" "$tmpdir/foo" "$tmpdir/restore/foo"
+WVPASS bup restore -C "$tmpdir/restore" "foo/latest/$tmpdir/foo/baz"
+WVPASS "$top/t/compare-trees" "$tmpdir/foo/baz" "$tmpdir/restore/baz"
rm -rf "$tmpdir"