Garbage collection never deletes orphaned files from storage

Aberta
#6,447 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
1/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
django, google-cloud, python
Domínio
backend, databases

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
JavaScript
Estrelas
214
Forks
327
Merge médio
17h 5min
PRs com merge (30d)
25

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de learningequality/studio

Todas as issues de learningequality/studio

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.