Skip to content

/uploads/<slug>/ retains orphan files after banner swap and remove #103

@vnykmshr

Description

@vnykmshr

Repro on v3.18.0:

  1. Edit a draft.
  2. Upload banner A → server stores /uploads/<slug>/<ts>-A.png; form points there.
  3. Upload banner B (swap) → server stores /uploads/<slug>/<ts>-B.png; form points to B. File A remains on disk.
  4. Click Remove → form clears banner + banner_alt. File B remains on disk.
  5. Re-upload C → form points to C. Files A and B both remain.
  6. Save draft → only the current file (C) is referenced by frontmatter; A and B are orphans.

Result on the reference deploy: a test draft session left three PNGs on disk; only manual rm -r /opt/<deploy>/uploads/<slug>/ cleaned them up post draft-delete.

Reasonable fix: on swap-replace, unlink the previous file. On remove, unlink the current file. On draft delete (when added — /admin/drafts currently has no Delete affordance), rm -r the slug's uploads dir. Per-slug GC sweep on startup is a bigger hammer that also works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions