mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-07 18:24:50 -04:00
add null check for source directory (#1248)
This commit is contained in:
parent
89d609e47b
commit
a85fa3fc54
@ -1,3 +1,4 @@
|
|||||||
|
import contextlib
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -27,25 +28,17 @@ class MealieAlphaMigrator(BaseMigrator):
|
|||||||
if recipe.get("categories", False):
|
if recipe.get("categories", False):
|
||||||
recipe["recipeCategory"] = recipe.get("categories")
|
recipe["recipeCategory"] = recipe.get("categories")
|
||||||
del recipe["categories"]
|
del recipe["categories"]
|
||||||
try:
|
|
||||||
|
with contextlib.suppress(KeyError):
|
||||||
del recipe["_id"]
|
del recipe["_id"]
|
||||||
del recipe["date_added"]
|
del recipe["date_added"]
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Migration from list to Object Type Data
|
# Migration from list to Object Type Data
|
||||||
try:
|
with contextlib.suppress(KeyError):
|
||||||
if "" in recipe["tags"]:
|
if "" in recipe["tags"]:
|
||||||
recipe["tags"] = [tag for tag in recipe["tags"] if tag != ""]
|
recipe["tags"] = [tag for tag in recipe["tags"] if tag != ""]
|
||||||
except Exception:
|
with contextlib.suppress(KeyError):
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
if "" in recipe["categories"]:
|
if "" in recipe["categories"]:
|
||||||
recipe["categories"] = [cat for cat in recipe["categories"] if cat != ""]
|
recipe["categories"] = [cat for cat in recipe["categories"] if cat != ""]
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if type(recipe["extras"]) == list:
|
if type(recipe["extras"]) == list:
|
||||||
recipe["extras"] = {}
|
recipe["extras"] = {}
|
||||||
|
|
||||||
@ -86,6 +79,9 @@ class MealieAlphaMigrator(BaseMigrator):
|
|||||||
if dest_dir.exists():
|
if dest_dir.exists():
|
||||||
shutil.rmtree(dest_dir)
|
shutil.rmtree(dest_dir)
|
||||||
|
|
||||||
|
if source_dir is None:
|
||||||
|
continue
|
||||||
|
|
||||||
for dir in source_dir.iterdir():
|
for dir in source_dir.iterdir():
|
||||||
if dir.is_dir():
|
if dir.is_dir():
|
||||||
shutil.copytree(dir, dest_dir / dir.name)
|
shutil.copytree(dir, dest_dir / dir.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user