Skip to content

Deleted release artifact files when they're cleared in admin #2021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bmispelon
Copy link
Member

@bmispelon bmispelon commented Apr 8, 2025

With this change, the artifact files are deleted from storage when the "clear" box is checked in the admin form:

Screenshot 2025-04-08 at 22-00-02 5 2 Change release Django site admin

Otherwise Django doesn't delete files from the storage (this is a documented behavior).

@bmispelon bmispelon force-pushed the release-delete-artifacts-on-clear branch from 9e8395a to 249762b Compare April 8, 2025 20:00
@bmispelon bmispelon force-pushed the release-delete-artifacts-on-clear branch from 249762b to bbc6fd7 Compare April 8, 2025 20:10
def test_clearing_also_deletes_file(self, commit_save=True):
tempdir = Path(tempfile.mkdtemp(prefix="djangoprojectcom_"))
self.addCleanup(shutil.rmtree, tempdir, ignore_errors=True)
self.enterContext(override_settings(MEDIA_ROOT=tempdir))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this exiting the context at some point? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes:

If successful, also add its __exit__() method as a cleanup function by addCleanup() [...]

My understanding is that this is equivalent to wrapping the whole method with override_settings(...) (which is not possible here because the overridden value of MEDIA_ROOT is dynamic.

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