upgrade_server: Return an empty response if no file available

This commit is contained in:
deajan 2024-09-17 14:04:00 +02:00
parent 5c3601fd90
commit 6f5e4b2035
2 changed files with 12 additions and 1 deletions

View file

@ -159,6 +159,9 @@ def auto_upgrader(
except (KeyError, TypeError):
logger.error("Cannot get file description")
return False
if sha256sum is None:
logger.info("No upgrade file found for me")
return False
file_data = requestor.requestor("download/" + id_record, raw=True)
if not file_data:

View file

@ -96,7 +96,15 @@ def get_file(file: FileGet, content: bool = False) -> Optional[Union[FileSend, b
)
logger.info("Searching for %s", path)
if not os.path.isfile(path):
return None
logger.info(f"No upgrade file found in {path}")
return FileSend(
arch=file.arch.value,
platform=file.platform.value,
sha256sum=None,
filename=None,
file_length=0,
)
with open(path, "rb") as fh:
bytes = fh.read()
if content: