mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-22 14:11:27 +00:00
delete --force: do not ask when deleting a repo, fixes #5941
This commit is contained in:
parent
a2b131dc2d
commit
d917c3a43b
1 changed files with 23 additions and 22 deletions
|
@ -1241,29 +1241,30 @@ def _delete_repository(self, args, repository):
|
||||||
keep_security_info = args.keep_security_info
|
keep_security_info = args.keep_security_info
|
||||||
|
|
||||||
if not args.cache_only:
|
if not args.cache_only:
|
||||||
msg = []
|
if args.forced == 0: # without --force, we let the user see the archives list and confirm.
|
||||||
try:
|
msg = []
|
||||||
manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
|
try:
|
||||||
except NoManifestError:
|
manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
|
||||||
msg.append("You requested to completely DELETE the repository *including* all archives it may "
|
except NoManifestError:
|
||||||
"contain.")
|
msg.append("You requested to completely DELETE the repository *including* all archives it may "
|
||||||
msg.append("This repository seems to have no manifest, so we can't tell anything about its "
|
"contain.")
|
||||||
"contents.")
|
msg.append("This repository seems to have no manifest, so we can't tell anything about its "
|
||||||
else:
|
"contents.")
|
||||||
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:
|
else:
|
||||||
msg.append("You requested to completely DELETE the repository *including* %d archives it contains."
|
if self.output_list:
|
||||||
% len(manifest.archives))
|
msg.append("You requested to completely DELETE the repository *including* all archives it "
|
||||||
msg.append("Type 'YES' if you understand this and want to continue: ")
|
"contains:")
|
||||||
msg = '\n'.join(msg)
|
for archive_info in manifest.archives.list(sort_by=['ts']):
|
||||||
if not yes(msg, false_msg="Aborting.", invalid_msg='Invalid answer, aborting.', truish=('YES',),
|
msg.append(format_archive(archive_info))
|
||||||
retry=False, env_var_override='BORG_DELETE_I_KNOW_WHAT_I_AM_DOING'):
|
else:
|
||||||
self.exit_code = EXIT_ERROR
|
msg.append("You requested to completely DELETE the repository *including* %d archives it contains."
|
||||||
return self.exit_code
|
% 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:
|
if not dry_run:
|
||||||
repository.destroy()
|
repository.destroy()
|
||||||
logger.info("Repository deleted.")
|
logger.info("Repository deleted.")
|
||||||
|
|
Loading…
Reference in a new issue