prevented overwriteing of files and modified the filename of things that require a date

This commit is contained in:
Marcel Gansfusz
2025-10-20 15:04:34 +02:00
parent 09e1e74af2
commit 93f2c59997
2 changed files with 15 additions and 3 deletions

Binary file not shown.

View File

@@ -24,6 +24,7 @@ import datetime
import logging import logging
import inspect import inspect
import pathlib
from starlette.types import HTTPExceptionHandler from starlette.types import HTTPExceptionHandler
@@ -607,9 +608,20 @@ def make_savepath(
400, 400,
"You have not specified a date for an upload that requires a date like an exam.", "You have not specified a date for an upload that requires a date like an exam.",
) )
filename += yyyy + "_" + mm + "_" + dd + "_" filename = yyyy + "_" + mm + "_" + dd + "_"
filename += fname + "." + ftype filename += fname
return savepath + filename file = filename + "." + ftype
destpath = pathlib.Path(savepath + file)
i = 0
info(destpath)
info(destpath.is_file())
while destpath.is_file():
file = filename + f"_{i}." + ftype
i += 1
destpath = pathlib.Path(savepath + file)
destpath.touch()
return savepath + file
def get_lvpath(lva: str) -> Tuple[int, str]: def get_lvpath(lva: str) -> Tuple[int, str]: