Garbage collection never deletes orphaned files from storage

Aperta
#6,447 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
1/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
django, google-cloud, python
Ambito
backend, databases

Direzione di ricerca

Read contentcuration/contentcuration/utils/garbage_collect.py and the named tests in contentcuration/contentcuration/tests/utils/test_garbage_collect.py; start by running the focused pytest command from the issue. The issue says contributions are not open for this task, so it is not suitable for a first contribution.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug DEV: backend

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: unstable

Observed behavior

_clean_up_files assigns a Django Exists(...) expression to is_other_node_pointing and tests if not is_other_node_pointing:. The expression is never run as a query, and an Exists object is always truthy, so default_storage.delete is never called. manage.py garbage_collect deletes the File rows of orphaned nodes and leaves their storage objects in the bucket.

User-facing consequences

Storage objects of garbage-collected content are never reclaimed, so the bucket only grows.

Steps to reproduce

  1. In test_deletes_associated_files, add assert not default_storage.exists("storage/a/a/aaa.jpg") after clean_up_contentnodes().
  2. Run pytest contentcuration/contentcuration/tests/utils/test_garbage_collect.py -k test_deletes_associated_files.
  3. The new assertion fails: the object is still stored.

Acceptance Criteria

  • After clean_up_contentnodes(), a storage object referenced only by File rows of the cleaned-up nodes no longer exists in default_storage.
  • A storage object also referenced by a File row outside the cleaned-up nodes still exists.
  • clean_up_contentnodes() completes when a File row's storage object is already absent: GoogleCloudStorage.delete raises AttributeError for a missing object.

AI usage

Claude Code (Fable 5.2) found this while planning #6445 and wrote the issue.

Lingua principale
JavaScript
Stelle
214
Fork
327
Merge medio
17h 5m
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di learningequality/studio

Tutte le issue di learningequality/studio

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.