]> arthur.barton.de Git - bup.git/commitdiff
find_dir_item_metadata_by_name(): wait for the right item name.
authorRob Browning <rlb@defaultvalue.org>
Sun, 10 Mar 2013 16:25:47 +0000 (11:25 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 10 Mar 2013 16:32:54 +0000 (11:32 -0500)
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>
cmd/restore-cmd.py
t/test-restore-single-file.sh

index 9089d9671590b9c26533389725a975640c5ad3dd..43209b3a3112d563e35c6c7440bac2076306c5ba 100755 (executable)
@@ -124,12 +124,13 @@ def find_dir_item_metadata_by_name(dir, name):
         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:
index b64a966be78df176340fa68d9ddcbcefa4ff314b..a0c429b653750912960227f718f3632da4b97afc 100755 (executable)
@@ -11,12 +11,15 @@ export BUP_DIR="$tmpdir/bup"
 
 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"