Permalink
Browse files

Merge pull request borgbackup#3450 from ThomasWaldmann/borg-delete-re…

…moving-security-dir

also delete security dir when deleting a repo, fixes borgbackup#3427
  • Loading branch information...
ThomasWaldmann committed Dec 18, 2017
2 parents 55ca8a9 + 8f77243 commit 1e9c90da2af8f38fa69ebf48550e28927e566e83
Showing with 9 additions and 1 deletion.
  1. +2 −1 src/borg/archiver.py
  2. +7 −0 src/borg/cache.py
@@ -38,7 +38,7 @@
from .archive import Archive, ArchiveChecker, ArchiveRecreater, Statistics, is_special
from .archive import BackupOSError, backup_io
from .archive import FilesystemObjectProcessors, MetadataCollector, ChunksProcessor
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
@@ -1108,6 +1108,7 @@ def _delete_repository(self, args, repository):
return self.exit_code
repository.destroy()
logger.info("Repository deleted.")
SecurityManager.destroy(repository)
Cache.destroy(repository)
logger.info("Cache deleted.")
return self.exit_code
@@ -66,6 +66,13 @@ def __init__(self, repository):
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)

0 comments on commit 1e9c90d

Please sign in to comment.