fix(download): dispatch archive/non-media in attach_in_place; reshuffle showcase on mount
attach_in_place mirrored only the media flow, so gallery-dl-downloaded zips/PDFs/audio bounced back as `skipped+invalid_image`, which download_service counted as an ingest error and flipped runs to status="error" despite N successful image attaches. Lustria patreon event #38998 (21 images + 1 OST zip) went red for exactly this reason. Now attach_in_place dispatches the same way as import_one: archives → _import_archive (extracts media members, captures archive as PostAttachment), non-media → _capture_attachment. Download_service accepts the new `attached` result and treats non-duplicate skips as soft skips, not ingest errors. Also: ShowcaseView always loadInitial() on mount, not just when the store is empty — Pinia persists across navigations and operator wants a fresh shuffle every time the showcase loads.
This commit is contained in:
@@ -159,3 +159,30 @@ def test_attach_in_place_invalid_image_returns_skipped(importer):
|
||||
result = importer.attach_in_place(bad)
|
||||
assert result.status == "skipped"
|
||||
assert result.skip_reason.value == "invalid_image"
|
||||
|
||||
|
||||
def test_attach_in_place_non_media_routes_to_attachment(importer, db_sync):
|
||||
"""FC-2d-iii dispatch parity for the download path. A non-media file
|
||||
(.pdf, .txt etc.) downloaded by gallery-dl must become a PostAttachment,
|
||||
not bounce back as `skipped+invalid_image` — the latter flipped
|
||||
otherwise-successful runs to status="error" downstream. Operator-flagged
|
||||
2026-06-02 (Lustria patreon OST zip)."""
|
||||
from backend.app.models import PostAttachment
|
||||
|
||||
images_root = importer.images_root
|
||||
artist = Artist(name="Gus", slug="gus")
|
||||
db_sync.add(artist)
|
||||
db_sync.flush()
|
||||
|
||||
txt = images_root / "gus" / "patreon" / "post" / "notes.txt"
|
||||
txt.parent.mkdir(parents=True, exist_ok=True)
|
||||
txt.write_bytes(b"some non-media payload that the importer should preserve")
|
||||
|
||||
result = importer.attach_in_place(txt, artist=artist)
|
||||
assert result.status == "attached"
|
||||
|
||||
row = db_sync.execute(
|
||||
select(PostAttachment).where(PostAttachment.original_filename == "notes.txt")
|
||||
).scalar_one()
|
||||
assert row.ext == ".txt"
|
||||
assert row.artist_id == artist.id
|
||||
|
||||
Reference in New Issue
Block a user