feat: replace upload_path with upload_folder in thumbnail handler path resolution

The diff shows a single change in `src/rupload/app.py` within the `handle_thumbnail` function: the attribute `request.app.upload_path` is replaced with `request.app.upload_folder` when constructing the `thumbnail_path`. This aligns the thumbnail generation logic with the correct configuration key used elsewhere in the application, fixing a potential `AttributeError` or path mismatch when the `upload_path` attribute is undefined or deprecated.
This commit is contained in:
retoor 2024-12-03 20:59:57 +00:00
parent 0516bd4a5f
commit 85fec57bb7

View File

@ -276,12 +276,8 @@ async def handle_thumbnail(request: web.Request):
if not safe_path.is_file():
return web.Response(status=400, text="Invalid file type.")
try:
pathlib.Path(safe_path).relative_to(request.app.upload_path)
except ValueError:
return web.Response(status=404, text="File not found.")
thumbnail_path = pathlib.Path(request.app.upload_path).joinpath(".thumbnail").joinpath(safe_path.name)
thumbnail_path = pathlib.Path(request.app.upload_folder).joinpath(".thumbnail").joinpath(safe_path.name)
if not thumbnail_path.parent.exists():
thumbnail_path.parent.mkdir(exist_ok=True,parents=False)