Image scale blobs no cleaned by zeopack after removing ScalesDict

Newer versions of Plone seem to store image scales (NamedBlobImage) while older versions of Plone stored scales in annotations directly within the ZODB..that'ok. As part of a migration I wrote some code to pure all image annotations by deleting the plone.scale annotation. After packing the ZODB, the number blob files remained identical. This is perhaps a bit surprising. Shouldn't the ZODB/zeopack remove unused blob files automatically?

Dexterity content types (plone.namedfile) use the type of the field for scales. NamedImageField stores its scales in ZODB, NamedBlobImageField stores its scales as blobs.

Results of pack IS surprising. Doesn't that mean that something in ZODB is still referring those blobs? Or simply the deletion was to recent to be backed?

Nope, I explicitly checked that the plone.scale annotation was removed. This observation is somewhat consistent with former vague observations that "newer" versions of Plone (or the ZODB) would not pack properly in the context of blob files.

I tried this with clean Plone. Deleting plone.scale annotation from OOTB Image content object worker properly. All scale blobs were gone after packing.

Then I added Lead image behavior for versioned OOTB Document content type. Now, there seems to be a bug we fixed for Mosaic tile annotations earlier: versioning crates zero size blobs into blob storage. Nevertheless, deleting plone.scale and packing removed all the current scales. Only the originals were left (and those zero sized blobs from "versioned scales").

Plone Foundation Code of Conduct