mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-20 21:27:32 +00:00
Merge pull request #6455 from Whissi/issue_6453
delete: add repository id and location to prompt
This commit is contained in:
commit
89f192edb2
1 changed files with 27 additions and 12 deletions
|
@ -1397,23 +1397,38 @@ def _delete_repository(self, args, repository):
|
||||||
|
|
||||||
if not args.cache_only:
|
if not args.cache_only:
|
||||||
if args.forced == 0: # without --force, we let the user see the archives list and confirm.
|
if args.forced == 0: # without --force, we let the user see the archives list and confirm.
|
||||||
|
id = bin_to_hex(repository.id)
|
||||||
|
location = repository._location.canonical_path()
|
||||||
msg = []
|
msg = []
|
||||||
try:
|
try:
|
||||||
manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
|
manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
|
||||||
|
n_archives = len(manifest.archives)
|
||||||
|
msg.append(f"You requested to completely DELETE the following repository "
|
||||||
|
f"*including* {n_archives} archives it contains:")
|
||||||
except NoManifestError:
|
except NoManifestError:
|
||||||
msg.append("You requested to completely DELETE the repository *including* all archives it may "
|
n_archives = None
|
||||||
"contain.")
|
msg.append("You requested to completely DELETE the following repository "
|
||||||
msg.append("This repository seems to have no manifest, so we can't tell anything about its "
|
"*including* all archives it may contain:")
|
||||||
"contents.")
|
|
||||||
else:
|
msg.append(DASHES)
|
||||||
if self.output_list:
|
msg.append(f"Repository ID: {id}")
|
||||||
msg.append("You requested to completely DELETE the repository *including* all archives it "
|
msg.append(f"Location: {location}")
|
||||||
"contains:")
|
|
||||||
for archive_info in manifest.archives.list(sort_by=['ts']):
|
if self.output_list:
|
||||||
msg.append(format_archive(archive_info))
|
msg.append("")
|
||||||
|
msg.append("Archives:")
|
||||||
|
|
||||||
|
if n_archives is not None:
|
||||||
|
if n_archives > 0:
|
||||||
|
for archive_info in manifest.archives.list(sort_by=['ts']):
|
||||||
|
msg.append(format_archive(archive_info))
|
||||||
|
else:
|
||||||
|
msg.append("This repository seems to not have any archives.")
|
||||||
else:
|
else:
|
||||||
msg.append("You requested to completely DELETE the repository *including* %d archives it contains."
|
msg.append("This repository seems to have no manifest, so we can't "
|
||||||
% len(manifest.archives))
|
"tell anything about its contents.")
|
||||||
|
|
||||||
|
msg.append(DASHES)
|
||||||
msg.append("Type 'YES' if you understand this and want to continue: ")
|
msg.append("Type 'YES' if you understand this and want to continue: ")
|
||||||
msg = '\n'.join(msg)
|
msg = '\n'.join(msg)
|
||||||
if not yes(msg, false_msg="Aborting.", invalid_msg='Invalid answer, aborting.', truish=('YES',),
|
if not yes(msg, false_msg="Aborting.", invalid_msg='Invalid answer, aborting.', truish=('YES',),
|
||||||
|
|
Loading…
Reference in a new issue