From: Johannes Berg Date: Sat, 25 Jan 2020 22:41:56 +0000 (+0100) Subject: save: don't confuse metadata on duplicate files X-Git-Tag: 0.31~105 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=bd0dc75dd161d544133cc80d4858bc8ef1511a7e save: don't confuse metadata on duplicate files 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 Reviewed-by: Rob Browning --- diff --git a/cmd/save-cmd.py b/cmd/save-cmd.py index 306e3fd..53cab3b 100755 --- a/cmd/save-cmd.py +++ b/cmd/save-cmd.py @@ -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.