From cf0262c8b4281556d3a30505cee18c793056036a Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Mon, 18 Jan 2016 18:12:44 +0100 Subject: [PATCH] Fix upgrade without ~/attic/keys existing. fixes #576 --- borg/upgrader.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/borg/upgrader.py b/borg/upgrader.py index bb47429eb..d836c57aa 100644 --- a/borg/upgrader.py +++ b/borg/upgrader.py @@ -267,10 +267,12 @@ class AtticKeyfileKey(KeyfileKey): 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)