]> 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>
Mon, 24 Feb 2020 01:40:06 +0000 (19:40 -0600)
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>
cmd/save-cmd.py

index 306e3fd5c5994868efe3d8a9dec9d510506d4761..53cab3be852520a48425954406876b30a8b8f85d 100755 (executable)
@@ -159,15 +159,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 = b'/'.join(parts) + b'/'
                 add_error('error: ignoring duplicate path %s in %s'
                           % (path_msg(name), path_msg(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
 
         if metalist:
             if dir_metadata: # Override the original metadata pushed for this dir.