1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-31 03:31:41 +00:00

Fix upgrade without ~/attic/keys existing.

fixes #576
This commit is contained in:
Profpatsch 2016-01-18 18:12:44 +01:00
parent 3b6fdbc57c
commit cf0262c8b4

View file

@ -267,10 +267,12 @@ def find_key_file(cls, repository):
get_keys_dir = cls.get_keys_dir
id = hexlify(repository.id).decode('ascii')
keys_dir = get_keys_dir()
if not os.path.exists(keys_dir):
raise KeyfileNotFoundError(repository.path, keys_dir)
for name in os.listdir(keys_dir):
filename = os.path.join(keys_dir, name)
with open(filename, 'r') as fd:
line = fd.readline().strip()
if line and line.startswith(cls.FILE_ID) and line[10:] == id:
return filename
raise KeyfileNotFoundError(repository.path, get_keys_dir())
raise KeyfileNotFoundError(repository.path, keys_dir)