mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-12 18:30:18 -04:00
transfer: validate archive names before transfer
This commit is contained in:
parent
fe2b2bc007
commit
ebff12ad41
1 changed files with 14 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ from ..archive import Archive
|
|||
from ..constants import * # NOQA
|
||||
from ..crypto.key import uses_same_id_hash, uses_same_chunker_secret
|
||||
from ..helpers import EXIT_SUCCESS, EXIT_ERROR, Error
|
||||
from ..helpers import location_validator, Location
|
||||
from ..helpers import location_validator, Location, archivename_validator
|
||||
from ..helpers import format_file_size
|
||||
from ..manifest import Manifest
|
||||
|
||||
|
|
@ -39,6 +39,19 @@ class TransferMixIn:
|
|||
if not archive_names:
|
||||
return EXIT_SUCCESS
|
||||
|
||||
an_errors = []
|
||||
av = archivename_validator()
|
||||
for archive_name in archive_names:
|
||||
try:
|
||||
av(archive_name)
|
||||
except argparse.ArgumentTypeError as err:
|
||||
an_errors.append(str(err))
|
||||
if an_errors:
|
||||
self.print_error("Invalid archive names detected, please rename them before transfer:")
|
||||
for err_msg in an_errors:
|
||||
self.print_error(err_msg)
|
||||
return EXIT_ERROR
|
||||
|
||||
from .. import upgrade as upgrade_mod
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue