浏览代码

don't clobber existing borg cache

Antoine Beaupré 9 年之前
父节点
当前提交
8022e563a9
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      borg/converter.py

+ 7 - 4
borg/converter.py

@@ -154,10 +154,13 @@ class AtticRepositoryConverter(Repository):
                 if not os.path.exists(borg_cache_dir):
                     os.makedirs(borg_cache_dir)
                 borg_cache = os.path.join(borg_cache_dir, cache)
-                print("copying attic cache from %s to %s" % (attic_cache, borg_cache))
-                if not dryrun:
-                    shutil.copy(attic_cache, borg_cache)
-                caches += [borg_cache]
+                if os.path.exists(borg_cache):
+                    print("borg cache already exists in %s, skipping conversion of %s" % (borg_cache, attic_cache))
+                else:
+                    print("copying attic cache from %s to %s" % (attic_cache, borg_cache))
+                    if not dryrun:
+                        shutil.copyfile(attic_cache, borg_cache)
+                    caches += [borg_cache]
             else:
                 print("no %s cache found in %s" % (cache, attic_cache))