1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-27 02:08:54 +00:00

Merge pull request #6209 from ThomasWaldmann/delete-repo-forced-master

delete --force: do not ask when deleting a repo, fixes #5941
This commit is contained in:
TW 2022-01-31 00:29:19 +01:00 committed by GitHub
commit 3a552b4c8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1241,29 +1241,30 @@ def _delete_repository(self, args, repository):
keep_security_info = args.keep_security_info
if not args.cache_only:
msg = []
try:
manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
except NoManifestError:
msg.append("You requested to completely DELETE the repository *including* all archives it may "
"contain.")
msg.append("This repository seems to have no manifest, so we can't tell anything about its "
"contents.")
else:
if self.output_list:
msg.append("You requested to completely DELETE the repository *including* all archives it "
"contains:")
for archive_info in manifest.archives.list(sort_by=['ts']):
msg.append(format_archive(archive_info))
if args.forced == 0: # without --force, we let the user see the archives list and confirm.
msg = []
try:
manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
except NoManifestError:
msg.append("You requested to completely DELETE the repository *including* all archives it may "
"contain.")
msg.append("This repository seems to have no manifest, so we can't tell anything about its "
"contents.")
else:
msg.append("You requested to completely DELETE the repository *including* %d archives it contains."
% len(manifest.archives))
msg.append("Type 'YES' if you understand this and want to continue: ")
msg = '\n'.join(msg)
if not yes(msg, false_msg="Aborting.", invalid_msg='Invalid answer, aborting.', truish=('YES',),
retry=False, env_var_override='BORG_DELETE_I_KNOW_WHAT_I_AM_DOING'):
self.exit_code = EXIT_ERROR
return self.exit_code
if self.output_list:
msg.append("You requested to completely DELETE the repository *including* all archives it "
"contains:")
for archive_info in manifest.archives.list(sort_by=['ts']):
msg.append(format_archive(archive_info))
else:
msg.append("You requested to completely DELETE the repository *including* %d archives it contains."
% len(manifest.archives))
msg.append("Type 'YES' if you understand this and want to continue: ")
msg = '\n'.join(msg)
if not yes(msg, false_msg="Aborting.", invalid_msg='Invalid answer, aborting.', truish=('YES',),
retry=False, env_var_override='BORG_DELETE_I_KNOW_WHAT_I_AM_DOING'):
self.exit_code = EXIT_ERROR
return self.exit_code
if not dry_run:
repository.destroy()
logger.info("Repository deleted.")