From 1d64e5c227f6d73a19adafb740e40e0739824ce5 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 16 Dec 2017 22:59:47 +0100 Subject: [PATCH] also delete security dir when deleting a repo, fixes #3427 (cherry picked from commit 8f772437f21c0a979e5eb922ead9efcb952d878c) --- src/borg/archiver.py | 3 ++- src/borg/cache.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index b2db6cc98..873762f4d 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -38,7 +38,7 @@ from . import shellpattern from .algorithms.checksums import crc32 from .archive import Archive, ArchiveChecker, ArchiveRecreater, Statistics, is_special from .archive import BackupOSError, backup_io -from .cache import Cache, assert_secure +from .cache import Cache, assert_secure, SecurityManager from .constants import * # NOQA from .compress import CompressionSpec from .crypto.key import key_creator, key_argument_names, tam_required_file, tam_required, RepoKey, PassphraseKey @@ -1303,6 +1303,7 @@ class Archiver: return self.exit_code repository.destroy() logger.info("Repository deleted.") + SecurityManager.destroy(repository) Cache.destroy(repository) logger.info("Cache deleted.") return self.exit_code diff --git a/src/borg/cache.py b/src/borg/cache.py index e996fa039..14f6460ef 100644 --- a/src/borg/cache.py +++ b/src/borg/cache.py @@ -66,6 +66,13 @@ class SecurityManager: self.location_file = os.path.join(self.dir, 'location') self.manifest_ts_file = os.path.join(self.dir, 'manifest-timestamp') + @staticmethod + def destroy(repository, path=None): + """destroy the security dir for ``repository`` or at ``path``""" + path = path or get_security_dir(repository.id_str) + if os.path.exists(path): + shutil.rmtree(path) + def known(self): return os.path.exists(self.key_type_file)