Adding download window which can prevent downloads from running at unwanted times.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

This commit is contained in:
Roland 2026-03-12 20:10:57 -06:00
parent 4579562be5
commit 35994bd363
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
10 changed files with 395 additions and 57 deletions

View file

@ -157,6 +157,8 @@ def get_settings(_: Request):
'download_on_startup': wrolpi_config.download_on_startup,
'download_timeout': wrolpi_config.download_timeout,
'download_wait': wrolpi_config.download_wait,
'download_window_start': wrolpi_config.download_window_start,
'download_window_end': wrolpi_config.download_window_end,
'hotspot_device': wrolpi_config.hotspot_device,
'hotspot_on_startup': wrolpi_config.hotspot_on_startup,
'hotspot_password': wrolpi_config.hotspot_password,
@ -230,6 +232,17 @@ async def update_settings(_: Request, body: schema.SettingsRequest):
elif not body.zims_destination:
new_config['zims_destination'] = wrolpi_config.default_config['zims_destination']
# Handle download window fields: empty string clears the value.
for field_name in ('download_window_start', 'download_window_end'):
value = getattr(body, field_name, None)
if value is not None:
if value == '':
new_config[field_name] = None
else:
if not re.match(r'^\d{2}:\d{2}$', value):
raise InvalidConfig(f'{field_name} must be in HH:MM format')
new_config[field_name] = value
log_level = new_config.pop('log_level', None)
if isinstance(log_level, int):
set_global_log_level(log_level)