浏览代码

Set previous_location on load instead of save

This caused a really stupid bug with borg config --cache, see
https://github.com/borgbackup/borg/issues/3304#issuecomment-371896766
Milkey Mouse 7 年之前
父节点
当前提交
4098f0f05c
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/borg/cache.py

+ 1 - 1
src/borg/cache.py

@@ -290,6 +290,7 @@ class CacheConfig:
             self.previous_location = recanonicalize_relative_location(previous_location, self.repository)
             self.previous_location = recanonicalize_relative_location(previous_location, self.repository)
         else:
         else:
             self.previous_location = None
             self.previous_location = None
+        self._config.set('cache', 'previous_location', self.repository._location.canonical_path())
 
 
     def save(self, manifest=None, key=None):
     def save(self, manifest=None, key=None):
         if manifest:
         if manifest:
@@ -304,7 +305,6 @@ class CacheConfig:
             self._config.set('integrity', 'manifest', manifest.id_str)
             self._config.set('integrity', 'manifest', manifest.id_str)
         if key:
         if key:
             self._config.set('cache', 'key_type', str(key.TYPE))
             self._config.set('cache', 'key_type', str(key.TYPE))
-        self._config.set('cache', 'previous_location', self.repository._location.canonical_path())
         with SaveFile(self.config_path) as fd:
         with SaveFile(self.config_path) as fd:
             self._config.write(fd)
             self._config.write(fd)