Skip to content

Conversation

@NillasKA
Copy link
Contributor

@NillasKA NillasKA commented Dec 4, 2025

Closes #8240

Description

Historically we have "neglected" the media folder that is created on disk when a media item is uploaded, neglected as in never deleting it when deleting the media item.

This fix introduces a lock, that should prevent race conditions when deleting this folder, and also contains a check to ensure that the folder is empty before deleting it.

I have added a Lazy injection of the ICoreScope provider, otherwise it'll create a circular dependency that will leave the application hanging on startup

To test

  1. Upload a media item, and observe that a folder is created on disk, containing this media item.
  2. Delete the media item from the backoffice (Fully, not just trashed)
  3. Observe that the folder is also deleted. Unless it contains more than the media item set for deletion.

Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

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

Logic seems good to me, but we're missing some tests ;)

@NillasKA NillasKA requested a review from Zeegaan December 5, 2025 09:25
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.

Give the option to delete media from disk when emptying the Media Recycle Bin

3 participants