Reuse live content-addressed blobs instead of replacing them.
This avoids ERROR_ACCESS_DENIED when a reader still has the existing
file open and keeps the reference count balanced.
---------
Co-authored-by: Tomauskasz <tomas.bitvinskas@gmail.com>
If someone removed the directory structure, or otherwise messed with
the files, there was a good chance that we'd end up in a panic.
This commit improves the error messaging produced by the blob
lease layer to provide the path as context, log the error,
and then translate the error case to an empty frame so that
the rest of the rendering machinery can proceed in a more reasonable
way.
We take care to log this sort of corrupt frame error only once,
as it is most likely to occur in an animated gif and will thus
trigger multiple times per second for such a file.
refs: #5422
When trying to display a 4k image there is a high chance that
we'll run out of texture space and then render with no images
displayed.
This commit changes the binary yes/no allow-images into a a series
of attempts: display at natural size, scale down by 2, 4, then 8,
then give up on images.
While looking at this, I noticed that we had a TOCTOU in the blob lease
stuff in the case where we might very quickly try the handle the same
image in succession, and end up deleting a file out from under a live
lease.
I've put in place a simple bandaid for that, but it's probably worth
revisiting the concurrency model for that.
The static OnceCell didn't run destructors, so shift to something
where we can explicitly trigger them to run and clean up the
temporary directory area.