Skip to content

Orphan files cleaning - #2752

Open
IdirLISN wants to merge 18 commits into
developfrom
fix/orphan_files_deletion
Open

IdirLISN wants to merge 18 commits into
developfrom
fix/orphan_files_deletion

Conversation

@IdirLISN

@IdirLISN IdirLISN commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR fixes the orphan files feature. In analytics, you can fetch all orphan files and removing them one by one or all of them. When an admin start a scan, other admin can see the scan on their own browser. We save the scan in database, displayed in django admin.

Features:

  • Async jobs in Site worker.
  • Scan by file type or all.
  • Prevention of concurrent scan and cleanup jobs.
  • Scan saved in DB.
  • Grace period in days, months or years.
  • Load last scan file to be able to delete resulted orphan files.
  • UI persistence when reloading page.
  • UI persistence between two browsers.
  • Report on UI.
  • Delete selected.
  • Delete all.
  • Delete by file type
  • Admin page with jobs (with status) and orphan files (with status).
  • Delete Admin action (jobs deletes on cascade files).

Issues this PR resolves

Warning

Contains migrations

A checklist for hand testing

  • Go to analytics page
  • Start scan
  • Remove files
image

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

@IdirLISN IdirLISN self-assigned this Nov 18, 2026
@IdirLISN
IdirLISN marked this pull request as draft November 18, 2026 15:36
@IdirLISN
IdirLISN requested review from Didayolo and ObadaS November 18, 2026 15:36
@IdirLISN
IdirLISN marked this pull request as ready for review November 19, 2026 10:05
@IdirLISN

Copy link
Copy Markdown
Collaborator Author

branch ready for tests @ObadaS @Didayolo

@Didayolo Didayolo changed the title Orphan files cleaning. Orphan files cleaning Nov 19, 2026
@Didayolo

Copy link
Copy Markdown
Member

Some feedback:

  • start_orphan_files_cleanup (api/views/analytics.py:457) passes "dry_run": True to cleanup_orphan_files_task. This setting does not exist, and I think we do not want it to be a dry run anyway.

  • The code only works if the buckets are literally called private and public. ALLOWED_PREFIXES uses the names "private"/"public", but references and scanned objects carry the actual bucket names (field.storage.bucket_name, settings.AWS_STORAGE_*_BUCKET_NAME). The scanner then keeps only buckets whose real name is in ALLOWED_PREFIXES (scanner.py:55).

@IdirLISN
IdirLISN marked this pull request as draft November 24, 2026 12:58
@IdirLISN
IdirLISN force-pushed the fix/orphan_files_deletion branch from 1e5b282 to 64f7c81 Compare November 25, 2026 09:23
@IdirLISN
IdirLISN marked this pull request as ready for review November 25, 2026 14:57
@IdirLISN
IdirLISN force-pushed the fix/orphan_files_deletion branch from 298950b to 5006d25 Compare December 2, 2026 08:59

This branch has not been deployed

No deployments
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.

Deleting Orphan Files Storage Analytics never completes

2 participants