From 2c00ee8d732afa853c7506c62d898d5e1a398ee8 Mon Sep 17 00:00:00 2001 From: Fledge Shiu Date: Mon, 11 Sep 2023 08:17:46 -0400 Subject: [PATCH] Add normalized filename function. --- backend/api/routes/__init__.py | 5 +++++ backend/api/routes/archives.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/backend/api/routes/__init__.py b/backend/api/routes/__init__.py index 9d929c3..67b6272 100644 --- a/backend/api/routes/__init__.py +++ b/backend/api/routes/__init__.py @@ -94,3 +94,8 @@ def generate_file_hash(file: BinaryIO) -> str: for chunk in read_file_in_chunks(file): hasher.update(chunk) return hasher.hexdigest() + + +def normalize_filename(filename): + # TODO: Normalize Filename + return filename diff --git a/backend/api/routes/archives.py b/backend/api/routes/archives.py index 6cdc272..72da666 100644 --- a/backend/api/routes/archives.py +++ b/backend/api/routes/archives.py @@ -18,6 +18,7 @@ from api.routes import ( calculate_file_size, generate_file_hash, + normalize_filename, save_file, validated_project, ) @@ -107,6 +108,8 @@ async def update_archive( session: Session = Depends(gen_session), ): """Update a metadata of a archive""" + config = archive_request.config.model_dump() + config["filename"] = normalize_filename(config.get("filename")) stmt = ( update(Archive) .filter_by(id=archive.id)