Merge pull request #3455 from ThomasWaldmann/borg-delete-removing-security-dir-1.1

also delete security dir when deleting a repo, fixes #3427 (1.1)
This commit is contained in:
TW 2017-12-18 04:12:48 +01:00 committed by GitHub
commit ed31ea2516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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)