models and hfcache tables

Co-authored-by: Copilot <copilot@github.com>
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2026-05-08 13:58:35 +02:00
parent 9dff73193e
commit 54ad469919
5 changed files with 61 additions and 41 deletions
+4 -2
View File
@@ -344,7 +344,7 @@ def get_deletefile(file: str):
import os
from pathlib import Path
allowed_dirs = shared.demo.allowed_paths
if not file.strip():
if file is None or len(file.strip()) == 0:
raise HTTPException(status_code=400, detail="file path is required")
if not any(Path(folder).absolute() in Path(file).absolute().parents for folder in allowed_dirs):
raise HTTPException(status_code=403, detail=f"file {file}: must be in one of allowed directories")
@@ -360,13 +360,14 @@ def get_deletefile(file: str):
os.remove(file)
return {"deleted": f"{file}"}
except Exception as e:
log.error(f'Delete: file="{file}" error: {e}')
raise HTTPException(status_code=500, detail=f"error deleting file {file}: {str(e)}") from e
def get_deleteimage(file: str):
import os
from pathlib import Path
allowed_dirs = shared.demo.allowed_paths
if not file.strip():
if file is None or len(file.strip()) == 0:
raise HTTPException(status_code=400, detail="file path is required")
if not any(Path(folder).absolute() in Path(file).absolute().parents for folder in allowed_dirs):
raise HTTPException(status_code=403, detail=f"file {file}: must be in one of allowed directories")
@@ -381,6 +382,7 @@ def get_deleteimage(file: str):
log.warning(f'Delete: image="{file}"')
return {"deleted": f"{file}"}
except Exception as e:
log.error(f'Delete: file="{file}" error: {e}')
raise HTTPException(status_code=500, detail=f"error deleting file {file}: {str(e)}") from e
def get_pnginfo(file: str):