Skip to content

The Paprika importer keeps photos, archive copies, ratings, and nutrition - #97

Merged
thebigjoe1 merged 4 commits into
TraceApps:devfrom
sreich:fix/paprika-import-photos
Nov 13, 2026
Merged

thebigjoe1 merged 4 commits into
TraceApps:devfrom
sreich:fix/paprika-import-photos

Conversation

@sreich

@sreich sreich commented Nov 13, 2026 •

Copy link
Copy Markdown

Importing a .paprikarecipes archive lost every photo, treated copies inside the same archive as duplicates, and dropped two fields. Four fixes, all verified against a real 275-recipe export.

What was broken

  • Photos never arrived. _importPaprika built the image data URL from r.photo, which holds a filename (photo_sJxG3k.jpg), not base64. Every embedded photo became a garbage data URL that the image localizer rejected — one warning per recipe, and img_url ended up null. The actual bytes live in photo_data (or photos[0].data on exports that use the list form).
  • Copies in the same archive ate each other. Dedup matches on case-insensitive name or source URL, and the commit loop checked against rows it had itself just inserted. Paprika's "recipe [copy]" entries — and unrelated recipes that merely share a source site — got skipped as duplicates of each other.
  • Ratings were dropped. The 0–5 rating field was never mapped.
  • nutritional_info was dropped. Present in the export, read by nothing.

What changed

  • _paprikaImgUrl(r) in both importers (server and client): photo_data || photos[0].data as a data URL; photo_url || image_url as a remote fallback.

  • _findImportDuplicate / _saveImportedRecipe take an optional excludeIds set. The import-zip commit loop, the bulk /import Paprika path, and both local-mode loops track the rows created in this batch and exclude them, so copies inside one archive land while cross-run dedup behaves exactly as before.

  • rating: r.rating > 0 ? r.rating : null in both importers and the local-mode payload.

  • _paprikaNotes(r) appends the nutritional_info text to notes under a Nutrition (from Paprika): heading.

  • Local mode: _localizeImportedImage decodes data URLs and stores them through the normal upload path (Capacitor Filesystem) rather than leaving base64 in the payload; commitRecipeZip also clears imgUrl when "import images" is off

Verification

A 275-recipe export, before & after:

before after
recipes created 264 275
false duplicate skips 11 0
stored images 0 240
ratings imported 0 63
nutrition in notes 0 202

The 240 stored images match the upload directory, and re-importing the same archive with skip-duplicates still skips all 275 — dedup across runs is unchanged.

Tests

New scripts/paprika-import.test.js (11 tests): functional in-memory zip-import coverage for each image source, the rating mapping, and the nutrition append, plus source assertions for the client-side copy and the excludeIds threading. Full suite: 1188 passing.

Paprika embeds each photo inside the .paprikarecipe JSON (photo_data,
or photos[0].data); `photo` is only the embedded filename. The importer
built a data URL out of the filename, so the magic-byte check rejected
every picture and imports arrived imageless. The bytes are now used,
with photo_url/image_url as a remote fallback, on the server and in the
client copy; local mode turns the data URL into a real file via
uploadImage instead of storing megabytes of base64 in the table.

A Paprika archive can also hold several user-made copies of one recipe
(same name or source URL, distinct entries). Batch imports now dedup
against the library the user had before the import, not against rows
written earlier in the same batch — on the server (/import-zip/commit
and /import) and in local mode (importRecipe and commitRecipeZip).
@thebigjoe1
thebigjoe1 merged commit 046be0b into TraceApps:dev Nov 13, 2026
thebigjoe1 added a commit that referenced this pull request Nov 13, 2026
…hone ratings and photo checks, small scan thumbnails (#97)
@thebigjoe1

Copy link
Copy Markdown
Contributor

Thanks! Merged, with a few changes on top: a recipe that's in the archive twice under the same name still imports once (copies and recipes from the same page import), ratings come through in the Android app too, and the bulk scan sends small thumbnails rather than whole photos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants