mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
fix: Make Nextcloud Migrations Fault Tolerant (#3544)
This commit is contained in:
parent
b0eece789d
commit
6991dff3e6
@ -243,6 +243,10 @@ class Recipe(RecipeSummary):
|
||||
|
||||
return {x.key_name: x.value for x in v} if v else {}
|
||||
|
||||
@field_validator("nutrition", mode="before")
|
||||
def validate_nutrition(cls, v):
|
||||
return v or None
|
||||
|
||||
@classmethod
|
||||
def loader_options(cls) -> list[LoaderOption]:
|
||||
return [
|
||||
|
@ -11,4 +11,4 @@ class Nutrition(MealieModel):
|
||||
fiber_content: str | None = None
|
||||
sodium_content: str | None = None
|
||||
sugar_content: str | None = None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
model_config = ConfigDict(from_attributes=True, coerce_numbers_to_str=True)
|
||||
|
@ -9,6 +9,8 @@ import isodate
|
||||
from isodate.isoerror import ISO8601Error
|
||||
from slugify import slugify
|
||||
|
||||
from mealie.schema.reports.reports import ReportEntryCreate
|
||||
|
||||
from ._migration_base import BaseMigrator
|
||||
from .utils.migration_alias import MigrationAlias
|
||||
from .utils.migration_helpers import MigrationReaders, glob_walker, import_image, split_by_comma
|
||||
@ -66,8 +68,19 @@ class NextcloudMigrator(BaseMigrator):
|
||||
|
||||
all_recipes = []
|
||||
for _, nc_dir in nextcloud_dirs.items():
|
||||
recipe = self.clean_recipe_dictionary(nc_dir.recipe)
|
||||
all_recipes.append(recipe)
|
||||
try:
|
||||
recipe = self.clean_recipe_dictionary(nc_dir.recipe)
|
||||
all_recipes.append(recipe)
|
||||
except Exception as e:
|
||||
self.logger.exception(e)
|
||||
self.report_entries.append(
|
||||
ReportEntryCreate(
|
||||
report_id=self.report_id,
|
||||
success=False,
|
||||
message=f"Failed to import {nc_dir.name}",
|
||||
exception=f"{e.__class__.__name__}: {e}",
|
||||
)
|
||||
)
|
||||
|
||||
all_statuses = self.import_recipes_to_database(all_recipes)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user