mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 13:35:23 +02:00
fix: check if the temp dir exists before deleting it (#2141)
This commit is contained in:
parent
05e2566c35
commit
d639bdcfe9
1 changed files with 3 additions and 1 deletions
|
@ -111,7 +111,9 @@ class AdminMaintenanceController(BaseAdminController):
|
|||
@router.post("/clean/temp", response_model=SuccessResponse)
|
||||
def clean_temp(self):
|
||||
try:
|
||||
shutil.rmtree(self.folders.TEMP_DIR)
|
||||
if self.folders.TEMP_DIR.exists():
|
||||
shutil.rmtree(self.folders.TEMP_DIR)
|
||||
|
||||
self.folders.TEMP_DIR.mkdir(parents=True, exist_ok=True)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=ErrorResponse.respond("Failed to clean temp")) from e
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue