Umbraco-cms: Cleanup empty media folders

Created on 12 Mar 2020  路  4Comments  路  Source: umbraco/Umbraco-CMS

I removed some media items and they went to the recycle bin, which is fine.
Then I emptied the recycle bin, and I saw that the files in the media folders (on disk) were removed, but the empty folders remain.
If you ask me it would be nice to cleanup those empty folders as well.

Umbraco version

I am seeing this issue on Umbraco version: 8.5.4

communitup-for-grabs typbug

All 4 comments

Sure thing, would be great! 馃憤

Hi @stefankip,

We're writing to let you know that we've added the Up For Grabs label to your issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post

Thanks muchly, from your friendly PR team bot :-)

Not sure if this can be marked up-to-grabs at the moment.

The implementation at MediaFileSystem.DeleteMediaFiles() already has the intention to delete the directory as well (empty or not, interestingly). However, it calls UniqueMediaPathScheme.GetDeleteDirectory() which now always returns null, which means no directory is ever deleted.

It is explicitly mentioned in the remarks this null is returned this to prevent the directory from being deleted because it could cause issues without having implemented locks in MediaFileSystem. An excerpt:

And, at the moment, we cannot delete directory "only if it is empty" because of race conditions. We'd need to implement locks in MediaFileSystem for this.

Because of this, I feel this may not be your typical up-for-grabs issue and perhaps it's better if HQ has a look at this?

Would HQ take a look at this? See comment from dknippers. Otherwise I guess no one will grab this.

After a while tons of empty directories remain on disk. In my case, ~43.000 empty directories which could also cause performance issues

Was this page helpful?
0 / 5 - 0 ratings