Skip to content

File visibility from published usage + reliable file deletion#641

Open
jirkamotejl wants to merge 12 commits into
masterfrom
feature/file-visibility-from-published-usage
Open

File visibility from published usage + reliable file deletion#641
jirkamotejl wants to merge 12 commits into
masterfrom
feature/file-visibility-from-published-usage

Conversation

@jirkamotejl

Copy link
Copy Markdown
Contributor

What

  • Folio::File#used_in_published_content? — live check whether a file is used in at least one published piece of content. Unwraps atoms to their parent record, respects the owner's published? (incl. published_at), ignores orphaned placements, counts owners without a publish concept as published. Early-exit batched iteration; single-record use only (collections need an SQL scope). Intended for host apps that derive public visibility of standalone file pages (e.g. video detail) from usage.
  • Reliable deletion — a stale file_placements_count no longer blocks file destroy. New Folio::File#live_indestructible_reason re-verifies the placements message with a live query; used by the model destroy guard, the console file detail and the API destroy. File lists keep the cheap counter. Host-app indestructible_reason overrides keep working (non-placements reasons pass through).
  • Console usage list — orphaned placements (owner deleted) are now rendered with the option to remove them (new orphan-only destroy endpoint, authorized via the file, fail-closed) instead of being silently skipped while blocking deletion. Each row shows a published/unpublished badge of the owning record. The usage section auto-expands when deletion is blocked.
  • Rake tasksfolio:files:recalculate_placement_counts (counter drift fix, DRY_RUN/ALL_VIDEOS) and folio:files:report_videos_without_published_usage (CSV report).
  • Tests pin the existing FriendlyId slug history cleanup (dependent: :destroy from friendly_id) and CRA media cleanup job enqueue on destroy — no behavior change there.

Notes

  • calculate_published_usage_count / published_usage_count semantics are intentionally unchanged (consumed by usage-limit licensing) — the new visibility check is a separate, documented measure.

Tests

Model, controller (console + API) and component tests included; suites green.

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.

1 participant