mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 13:35:23 +02:00
fix: Paprika Migration Error (#2834)
* made migration more fault tolerant * added edgecase for recipes with no ings/instructions * keep log for debugging --------- Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
parent
92d955172d
commit
861e8ac564
2 changed files with 7 additions and 3 deletions
|
@ -209,7 +209,11 @@ class BaseMigrator(BaseService):
|
|||
continue
|
||||
|
||||
if alias.func:
|
||||
prop_value = alias.func(prop_value)
|
||||
try:
|
||||
prop_value = alias.func(prop_value)
|
||||
except Exception as e:
|
||||
self.logger.exception(e)
|
||||
continue
|
||||
|
||||
recipe_dict[alias.key] = prop_value
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class PaprikaMigrator(BaseMigrator):
|
|||
re_num_list = re.compile(r"^\d+\.\s")
|
||||
|
||||
self.key_aliases = [
|
||||
MigrationAlias(key="recipeIngredient", alias="ingredients", func=lambda x: x.split("\n")),
|
||||
MigrationAlias(key="recipeIngredient", alias="ingredients", func=lambda x: x.split("\n") if x else ""),
|
||||
MigrationAlias(key="orgURL", alias="source_url", func=None),
|
||||
MigrationAlias(key="totalTime", alias="total_time", func=None),
|
||||
MigrationAlias(key="prepTime", alias="prep_time", func=None),
|
||||
|
@ -62,7 +62,7 @@ class PaprikaMigrator(BaseMigrator):
|
|||
MigrationAlias(
|
||||
key="recipeInstructions",
|
||||
alias="directions",
|
||||
func=lambda x: [{"text": re.sub(re_num_list, "", s)} for s in x.split("\n\n")],
|
||||
func=lambda x: [{"text": re.sub(re_num_list, "", s)} for s in x.split("\n\n")] if x else [],
|
||||
),
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue