Skip to content

Commit

Permalink
Add normalized filename function.
Browse files Browse the repository at this point in the history
  • Loading branch information
FledgeXu committed Sep 11, 2023
1 parent 65751bc commit 2c00ee8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/api/routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check notice on line 100 in backend/api/routes/__init__.py

View check run for this annotation

codefactor.io / CodeFactor

backend/api/routes/__init__.py#L100

unresolved comment '# TODO: Normalize Filename' (C100)
return filename
3 changes: 3 additions & 0 deletions backend/api/routes/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from api.routes import (
calculate_file_size,
generate_file_hash,
normalize_filename,
save_file,
validated_project,
)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2c00ee8

Please sign in to comment.