OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Remove Media files for a removed tenant when using Azure Blob Storage

Open Piedone opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

If you remove a tenant, its Media files are only removed if they use the default local storage in App_Data. When using Azure Blob Storage though, they remain.

Similar to https://github.com/OrchardCMS/OrchardCore/issues/16404.

Related: https://github.com/OrchardCMS/OrchardCore/issues/4950.

Describe the solution you'd like

Add an IShellRemovingHandler to OrchardCore.Media.Azure that removes Media files from Azure Blob Storage too. This should support both removing the whole container if tenants' Media are stored in separate containers, or just the "folder" if a single container is used.

Describe alternatives you've considered

You can also have a custom IShellRemovingHandler implementation for this, but I think this should be a core functionality.

Piedone avatar Jul 05 '24 12:07 Piedone

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

github-actions[bot] avatar Jul 11 '24 17:07 github-actions[bot]

What I've found is the logic to remove the container upon tenant deletion is already there, but it's not run because the corresponding settings are bugged (i.e. setting RemoveContainer to true in appsettings does not actually take effect). With a fix in place for that, the container is indeed deleted along with the tenant.

This should support both removing the whole container if tenants' Media are stored in separate containers, or just the "folder" if a single container is used.

To account for this, the existing settings could be extended with an additional flag (e.g. RemoveFilesFromBasePath), which could then determine whether to delete the container or only the files that are associated with the given base path. So, if I understand correctly, there's no need for a new handler here, only have to extend settings and the logic within RemovingAsync() in the above linked file.

porgabi avatar Apr 23 '25 17:04 porgabi

Yes, indeed, this just needs to be extended by the folder deletion, and a config for that.

Piedone avatar Apr 23 '25 19:04 Piedone