Skip to content

Reuse delete_stale_attachments command - #348

Merged
atodorov merged 1 commit into
masterfrom
refactor-stale-attachments
Oct 5, 2026
Merged

atodorov merged 1 commit into
masterfrom
refactor-stale-attachments

Conversation

@kiwitcms-bot

@kiwitcms-bot kiwitcms-bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Refactor remove_stale_tenant_attachments so it inherits from attachments.management.commands.delete_stale_attachments.Command (django-attachments) and delegates the removal of attachments whose related object is gone to super().handle(), once per tenant.

handle() only adds the multi-tenant loop plus two tenant-specific extras:

  • --dry-run: answer is forced to n before looping, so the upstream command reports each match without deleting.
  • --check-storage: not supported upstream, so the extra pass over attachments whose file is missing is done here.

The -y/--yes option comes from upstream; a new dry-run test is added, and the empty-object_id fixtures/assertions are dropped since that case is no longer special-cased. tcms_tenants/tests/test_remove_stale_tenant_attachments.py passes.

@kiwitcms-bot
kiwitcms-bot force-pushed the refactor-stale-attachments branch 4 times, most recently from 1f12eff to 2622664 Compare October 5, 2026 12:30
@kiwitcms-bot
kiwitcms-bot force-pushed the refactor-stale-attachments branch from 2622664 to 77484ed Compare October 5, 2026 12:32
@atodorov
atodorov merged commit 8735c71 into master Oct 5, 2026
7 checks passed
@atodorov
atodorov deleted the refactor-stale-attachments branch October 5, 2026 13:23
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.

2 participants