mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-07 14:35:25 +02:00
fixed breaking change with temp dir injection
This commit is contained in:
parent
a840cb0800
commit
254b6ae118
1 changed files with 3 additions and 3 deletions
|
@ -5,7 +5,7 @@ from pathlib import Path
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
import fastapi
|
import fastapi
|
||||||
from fastapi import Depends, HTTPException, Request, status
|
from fastapi import BackgroundTasks, Depends, HTTPException, Request, status
|
||||||
from fastapi.security import OAuth2PasswordBearer
|
from fastapi.security import OAuth2PasswordBearer
|
||||||
from jose import JWTError, jwt
|
from jose import JWTError, jwt
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
@ -215,14 +215,14 @@ async def temporary_zip_path() -> AsyncGenerator[Path, None]:
|
||||||
temp_path.unlink(missing_ok=True)
|
temp_path.unlink(missing_ok=True)
|
||||||
|
|
||||||
|
|
||||||
async def temporary_dir() -> AsyncGenerator[Path, None]:
|
async def temporary_dir(background_tasks: BackgroundTasks) -> AsyncGenerator[Path, None]:
|
||||||
temp_path = app_dirs.TEMP_DIR.joinpath(uuid4().hex)
|
temp_path = app_dirs.TEMP_DIR.joinpath(uuid4().hex)
|
||||||
temp_path.mkdir(exist_ok=True, parents=True)
|
temp_path.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield temp_path
|
yield temp_path
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(temp_path)
|
background_tasks.add_task(shutil.rmtree, temp_path)
|
||||||
|
|
||||||
|
|
||||||
def temporary_file(ext: str = "") -> Callable[[], Generator[tempfile._TemporaryFileWrapper, None, None]]:
|
def temporary_file(ext: str = "") -> Callable[[], Generator[tempfile._TemporaryFileWrapper, None, None]]:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue