Skip to content

Commit

Permalink
Add parents=True to mkdir calls in backend
Browse files Browse the repository at this point in the history
- if parent dir is missing it is now created instead of raising an error
- resolves #180
  • Loading branch information
lkeegan committed Nov 22, 2024
1 parent 579ef10 commit 1db7304
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def update_i18n(
):
language = get(session, Language, language_id)
i18json_path = i18n_language_path(language.id)
i18json_path.parent.mkdir(exist_ok=True)
i18json_path.parent.mkdir(parents=True, exist_ok=True)
with open(i18json_path, "w", encoding="utf-8") as i18json_file:
json.dump(i18dict, i18json_file, separators=(",", ":"), ensure_ascii=False)
return {"ok": True}
Expand Down
2 changes: 1 addition & 1 deletion mondey_backend/src/mondey_backend/routers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def write_image_file(file: UploadFile, filename: pathlib.Path | str):
image_max_height = 1024
image_quality = 90
try:
pathlib.Path(filename).parent.mkdir(exist_ok=True)
pathlib.Path(filename).parent.mkdir(parents=True, exist_ok=True)
with Image.open(file.file) as img:
# remove EXIF Orientation tag if present
ImageOps.exif_transpose(img, in_place=True)
Expand Down

0 comments on commit 1db7304

Please sign in to comment.