]> arthur.barton.de Git - bup.git/commitdiff
save: don't confuse metadata on duplicate files
authorJohannes Berg <johannes@sipsolutions.net>
Sat, 25 Jan 2020 22:41:56 +0000 (23:41 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sat, 25 Apr 2020 19:24:35 +0000 (14:24 -0500)
If there are duplicate files, save removes the duplicates but
doesn't remove the duplicates from metadata, so the metadata
list gets messed up wrt. the file list. Fix this.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
(cherry picked from commit bd0dc75dd161d544133cc80d4858bc8ef1511a7e)
[rlb@defaultvalue.org: adapt to 0.3x]
Tested-by: Rob Browning <rlb@defaultvalue.org>
cmd/save-cmd.py

index 36cd43a009335f8a62f4cbb6998bda037fa66024..43f41e7477ad4a609f32efd9b079a32c1c643b8a 100755 (executable)
@@ -158,15 +158,20 @@ def _pop(force_tree, dir_metadata=None):
     else:
         names_seen = set()
         clean_list = []
+        metaidx = 1 # entry at 0 is for the dir
         for x in shalist:
             name = x[1]
             if name in names_seen:
                 parent_path = '/'.join(parts) + '/'
                 add_error('error: ignoring duplicate path %r in %r'
                           % (name, parent_path))
+                if not stat.S_ISDIR(x[0]):
+                    del metalist[metaidx]
             else:
                 names_seen.add(name)
                 clean_list.append(x)
+                if not stat.S_ISDIR(x[0]):
+                    metaidx += 1
         tree = w.new_tree(clean_list)
     if shalists:
         shalists[-1].append((GIT_MODE_TREE,