Sfoglia il codice sorgente

Merge pull request #1709 from ThomasWaldmann/fix-1700

better messages for cache newer than repo, fixes #1700
enkore 8 anni fa
parent
commit
2e5b2b150b
1 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 8 2
      borg/cache.py

+ 8 - 2
borg/cache.py

@@ -20,8 +20,11 @@ import msgpack
 class Cache:
     """Client Side cache
     """
+    class RepositoryIDNotUnique(Error):
+        """Cache is newer than repository - do you have multiple, independently updated repos with same ID?"""
+
     class RepositoryReplay(Error):
-        """Cache is newer than repository, refusing to continue"""
+        """Cache is newer than repository - this is either an attack or unsafe (multiple repos with same ID)"""
 
     class CacheInitAbortedError(Error):
         """Cache initialization aborted"""
@@ -84,7 +87,10 @@ class Cache:
             if sync and self.manifest.id != self.manifest_id:
                 # If repository is older than the cache something fishy is going on
                 if self.timestamp and self.timestamp > manifest.timestamp:
-                    raise self.RepositoryReplay()
+                    if isinstance(key, PlaintextKey):
+                        raise self.RepositoryIDNotUnique()
+                    else:
+                        raise self.RepositoryReplay()
                 # Make sure an encrypted repository has not been swapped for an unencrypted repository
                 if self.key_type is not None and self.key_type != str(key.TYPE):
                     raise self.EncryptionMethodMismatch()