1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

fix FilesCacheMode validator

This commit is contained in:
Thomas Waldmann 2023-04-12 01:18:05 +02:00
parent 6d38530ff1
commit 0f923c8c4a
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -183,11 +183,13 @@ def FilesCacheMode(s):
VALID_MODES = ("cis", "ims", "cs", "ms", "cr", "mr", "d", "s") # letters in alpha order
entries = set(s.strip().split(","))
if not entries <= set(ENTRIES_MAP):
raise ValueError("cache mode must be a comma-separated list of: %s" % ",".join(sorted(ENTRIES_MAP)))
raise argparse.ArgumentTypeError(
"cache mode must be a comma-separated list of: %s" % ",".join(sorted(ENTRIES_MAP))
)
short_entries = {ENTRIES_MAP[entry] for entry in entries}
mode = "".join(sorted(short_entries))
if mode not in VALID_MODES:
raise ValueError("cache mode short must be one of: %s" % ",".join(VALID_MODES))
raise argparse.ArgumentTypeError("cache mode short must be one of: %s" % ",".join(VALID_MODES))
return mode