From d350e3a2e1447c0d3a4d4a1adee87b2825a5a345 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Sun, 22 Jan 2017 02:21:26 +0100 Subject: [PATCH] create: don't create hard link refs to failed files --- borg/archive.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/borg/archive.py b/borg/archive.py index 26ad16455..4d436c860 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -660,8 +660,6 @@ def process_file(self, path, st, cache, ignore_inode=False): self.add_item(item) status = 'h' # regular file, hardlink (to already seen inodes) return status - else: - self.hard_links[st.st_ino, st.st_dev] = safe_path is_special_file = is_special(st.st_mode) if not is_special_file: path_hash = self.key.id_hash(os.path.join(self.cwd, path).encode('utf-8', 'surrogateescape')) @@ -709,6 +707,9 @@ def process_file(self, path, st, cache, ignore_inode=False): item[b'mode'] = stat.S_IFREG | stat.S_IMODE(item[b'mode']) self.stats.nfiles += 1 self.add_item(item) + if st.st_nlink > 1 and source is None: + # Add the hard link reference *after* the file has been added to the archive. + self.hard_links[st.st_ino, st.st_dev] = safe_path return status @staticmethod