mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-28 13:05:26 -05:00
fix: Fix file not found error with individual recipe export/download. (#3579)
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import Depends, File, HTTPException, UploadFile, status
|
||||
from fastapi import File, HTTPException, UploadFile, status
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.core.dependencies.dependencies import temporary_dir
|
||||
from mealie.core.dependencies import get_temporary_path
|
||||
from mealie.pkgs import cache, img
|
||||
from mealie.routes._base import BaseUserController, controller
|
||||
from mealie.routes._base.routers import UserAPIRouter
|
||||
@@ -21,19 +20,19 @@ class UserImageController(BaseUserController):
|
||||
self,
|
||||
id: UUID4,
|
||||
profile: UploadFile = File(...),
|
||||
temp_dir: Path = Depends(temporary_dir),
|
||||
):
|
||||
"""Updates a User Image"""
|
||||
assert_user_change_allowed(id, self.user)
|
||||
temp_img = temp_dir.joinpath(profile.filename)
|
||||
with get_temporary_path() as temp_path:
|
||||
assert_user_change_allowed(id, self.user)
|
||||
temp_img = temp_path.joinpath(profile.filename)
|
||||
|
||||
with temp_img.open("wb") as buffer:
|
||||
shutil.copyfileobj(profile.file, buffer)
|
||||
with temp_img.open("wb") as buffer:
|
||||
shutil.copyfileobj(profile.file, buffer)
|
||||
|
||||
image = img.PillowMinifier.to_webp(temp_img)
|
||||
dest = PrivateUser.get_directory(id) / "profile.webp"
|
||||
image = img.PillowMinifier.to_webp(temp_img)
|
||||
dest = PrivateUser.get_directory(id) / "profile.webp"
|
||||
|
||||
shutil.copyfile(image, dest)
|
||||
shutil.copyfile(image, dest)
|
||||
|
||||
self.repos.users.patch(id, {"cache_key": cache.new_key()})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user