Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix encoding issue when seeding the database with foods, units and labels #2048

Merged
merged 1 commit into from
Jan 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mealie/repos/seed/seeders.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_file(self, locale: str | None = None) -> pathlib.Path:
def load_data(self, locale: str | None = None) -> Generator[MultiPurposeLabelSave, None, None]:
file = self.get_file(locale)

for label in json.loads(file.read_text()):
for label in json.loads(file.read_text(encoding="utf-8")):
yield MultiPurposeLabelSave(
name=label["name"],
group_id=self.group_id,
Expand All @@ -40,7 +40,7 @@ def get_file(self, locale: str | None = None) -> pathlib.Path:
def load_data(self, locale: str | None = None) -> Generator[SaveIngredientUnit, None, None]:
file = self.get_file(locale)

for unit in json.loads(file.read_text()).values():
for unit in json.loads(file.read_text(encoding="utf-8")).values():
yield SaveIngredientUnit(
group_id=self.group_id,
name=unit["name"],
Expand All @@ -65,7 +65,7 @@ def get_file(self, locale: str | None = None) -> pathlib.Path:
def load_data(self, locale: str | None = None) -> Generator[SaveIngredientFood, None, None]:
file = self.get_file(locale)

seed_foods: dict[str, str] = json.loads(file.read_text())
seed_foods: dict[str, str] = json.loads(file.read_text(encoding="utf-8"))
for food in seed_foods.values():
yield SaveIngredientFood(
group_id=self.group_id,
Expand Down