changed from string paths tp pathlib

This commit is contained in:
Marcel Gansfusz
2025-10-29 12:14:32 +01:00
parent e6727daf8e
commit da316a9351
2 changed files with 11 additions and 11 deletions

View File

@@ -193,7 +193,7 @@ async def get_file(file_id: str):
# status_code=500, detail="Somethings wrong with the database"
# )
# filename = cur.fetchone()[0]
return FileResponse(FILES_IN_PROGRESS + filename)
return FileResponse(FILES_IN_PROGRESS / filename)
@app.get("/search/lva")
@@ -534,8 +534,8 @@ async def yield_censor_status(file_id: str):
def censor_pdf(
path: str,
destpath: str,
path: os.PathLike,
destpath: os.PathLike,
rects: List[List[List[float]]],
scales: List[Dict[str, float]],
file_id: str,
@@ -582,8 +582,8 @@ def censor_pdf(
def censor_pdf_ocr(
path: str,
destpath: str,
path: os.PathLike,
destpath: os.PathLike,
rects: List[List[List[float]]],
scales: List[Dict[str, float]],
file_id: str,
@@ -692,14 +692,14 @@ def make_savepath(
) -> os.PathLike:
"""Generates the path, the file is saved to after the upload process is finished. It creates all nessecery directories."""
lv = get_lvpath(lva)
lvpath = lv[1] + "/"
lvpath = Path(lv[1])
pf = get_profpath(prof, lv[0])
pfpath = pf[1] + "/"
catpath = CATEGORIES[int(cat)] + "/"
pfpath = Path(pf[1])
catpath = Path(CATEGORIES[int(cat)])
scpath = ""
if int(cat) in SUBCAT_CATEGORIES_I and subcat != "":
sc = get_subcatpath(subcat, int(cat), pf[0], lv[0])
scpath = sc[1] + "/"
scpath = Path(sc[1])
if int(cat) == 6:
savepath = UNIZEUG_PATH / (lv[1] + "_Multimedia_only/") / pfpath
else:
@@ -958,7 +958,7 @@ async def remove_old_FIP_entrys():
# return_result=False,
# )
db.commit()
return FileResponse(APP_ROOT_PATH / "/index.html")
return FileResponse(APP_ROOT_PATH / "index.html")
def delete_from_FIP(uuid: str):
@@ -966,4 +966,4 @@ def delete_from_FIP(uuid: str):
if len(res) < 1:
raise HTTPException(500, "I am trying to delete a file that dose not exist")
sql("DELETE FROM FIP WHERE id=?", (uuid,), return_result=False, commit=True)
os.remove(FILES_IN_PROGRESS + res[0]["filename"])
os.remove(FILES_IN_PROGRESS / res[0]["filename"])