Skip to content

storage: converted/ holds 5.7MB of scratch PDFs nothing ever deletes #56

Description

@LevMuchnik

Found during the /plan-eng-review of #45.

normalize._image_to_pdf (backend/processing/normalize.py:104-105) and _html_to_pdf (:114-115) write storage/converted/<stem>_converted.pdf. pipeline.py:53 then save_converteds that to storage/converted/<hash>.pdf and walks away. Nothing deletes the scratch file.

Only gmail.py:180 and :199 clean up, and only on their success paths.

Measured live: 66 files in converted/ — 33 real <hash>.pdf and 33 <hash>_converted.pdf, 5.7MB of pure duplicate, i.e. converted/ is roughly twice the size it needs to be.

Two structural notes worth recording:

  1. save_converted has an exists-guard (backend/storage.py:33) while _image_to_pdf rewrites the scratch on every reprocess. So <hash>.pdf is the oldest conversion and <hash>_converted.pdf is the newest — the intuition is backwards. Measured: 31 of 33 pairs byte-identical, 2 differ (same size, different bytes — PDF /CreationDate). Change page_render_dpi once and <hash>.pdf is a conversion at a DPI nothing else in the system uses.
  2. gmail.py:175 calls normalize_file on a system tempfile, so a failure between the write and the unlink leaks converted/tmpXXXXXXXX_converted.pdf — a name nothing will ever match.

#45 excludes the paired scratch from backups (when the partner exists and is the same size). It deliberately does not delete anything from the live tree — that is this issue.

Related: #45, #46, #51.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions