Update exclude_larger_than unit check

This commit is contained in:
Orsiris de Jong 2024-02-05 19:36:39 +01:00
parent ae00a1db1c
commit eaf59fdd0e

View file

@ -23,6 +23,7 @@ from copy import deepcopy
from command_runner import command_runner from command_runner import command_runner
from ofunctions.threading import threaded from ofunctions.threading import threaded
from ofunctions.platform import os_arch from ofunctions.platform import os_arch
from ofunctions.misc import BytesConverter
from npbackup.restic_metrics import restic_str_output_to_json, restic_json_to_prometheus, upload_metrics from npbackup.restic_metrics import restic_str_output_to_json, restic_json_to_prometheus, upload_metrics
from npbackup.restic_wrapper import ResticRunner from npbackup.restic_wrapper import ResticRunner
from npbackup.core.restic_source_binary import get_restic_internal_binary from npbackup.core.restic_source_binary import get_restic_internal_binary
@ -883,26 +884,13 @@ class NPBackupRunner:
"backup_opts.exclude_files_larger_than" "backup_opts.exclude_files_larger_than"
) )
if exclude_files_larger_than: if exclude_files_larger_than:
if not exclude_files_larger_than[-1] in ( try:
"k", BytesConverter(exclude_files_larger_than)
"K", except ValueError:
"m", warning = f"Bogus unit for exclude_files_larger_than value given: {exclude_files_larger_than}"
"M",
"g",
"G",
"t",
"T",
):
warning = f"Bogus suffix for exclude_files_larger_than value given: {exclude_files_larger_than}"
self.write_logs( warning, level="warning") self.write_logs( warning, level="warning")
warnings.append(warning) warnings.append(warning)
exclude_files_larger_than = None exclude_files_larger_than = None
try:
float(exclude_files_larger_than[:-1])
except (ValueError, TypeError):
warning = f"Cannot check whether excludes_files_larger_than is a float: {exclude_files_larger_than}"
self.write_logs(warning, level="warning")
warnings.append(warning)
exclude_files_larger_than = None exclude_files_larger_than = None
one_file_system = ( one_file_system = (