瀏覽代碼

create: don't create hard link refs to failed files

Marian Beermann 8 年之前
父節點
當前提交
d350e3a2e1
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      borg/archive.py

+ 3 - 2
borg/archive.py

@@ -660,8 +660,6 @@ Number of files: {0.stats.nfiles}'''.format(
                 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 @@ Number of files: {0.stats.nfiles}'''.format(
             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