Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
That is very strange because this is the literal implementation of DeleteByPrefix
public void DeleteByPrefix(string directoryName)
{
if (string.IsNullOrEmpty(directoryName))
{
throw new ArgumentNullException(nameof(directoryName));
}
foreach (var blob in _container.GetBlobs(prefix: directoryName).Where(b => !b.Deleted))
{
_container.GetBlobClient(blob.Name).DeleteIfExists();
}
}
so no folder deleting before. or are we talking about different things?
_container.GetBlobs returns both the folder and the blobs inside the folder. Which is correct, because you also want to delete the folder. But it should happen after the blobs in the folder are deleted.
I just added .OrderByDescending(b => b.Name) to get it to work.
We have an issue with the BlobCleanupJob failing. Error message says that it can't delete a folder that is not empty.
After digging deep in the code for this scheduled job I have pinpointed where the error occurs.
The job fetches "ContentDeletedItemsActivity" from the ActivityQueryService and tries to delete blobs/folders in Azure storage. When the deleted item is a folder the deletion happens in method DeleteByPrefix in EPiServer.Azure.Blobs.Internal.DefaultAzureBlobContainer.
In that method the _container.GetBlobs fetches the folder and all blobs in the folder, and tries to delete them one by one. But it starts by trying to delete the folder, before the blobs are deleted!
I made a copy of the scheduled job and the DefaultAzureBlobContainer and simply reversed the order of the BlobItem collection before deleting them, and that works fine.
I'm able to reproduce the issue by simply creating new assetsfolder adding an image to that folder, move the folder to trash, empty the trash, and then run the "Remove Abandoned BLOBs" job.
We're on EPiServer.CMS 12.31.2. Is this a known issue?