jrrdnx / craft-cloudflare-r2

MIT License
6 stars 3 forks source link

Filesystem sync issues #5

Closed FreekVR closed 1 year ago

FreekVR commented 1 year ago

Hi! First of all thanks for the plugin. I've found two possible bugs that may or may not be related to the plugin or craft itself.

I've noticed when removing media, it doesn't remove all the image transforms from R2. The same thing happens when you replace a file with another file with the same name -- it doesn't replace/remove the transforms. It does seem to do this for the predefined image transforms, but not the ones created from twig/graphql with dynamic dimensions.

When replacing an image with another image with a different name, it will create renamed transforms for the new file but also not remove existing transforms.

Another perhaps related issue is that the "Asset indexes" update will prompt you to delete all the files from R2 -- it doesn't seem to be able to find them in the remote filesystem? I also cannot restore them from the R2 filesystem back into the asset index this way.

jrrdnx commented 1 year ago

Hi @FreekVR , you're welcome!

I've noticed when removing media, it doesn't remove all the image transforms from R2

I may need to do some testing here to see if this is on Craft's side or the plugin side. This plugin is essentially a fork of Craft's own S3 plugin so it should work exactly the same, so it could be a Craft bug or a limitation of R2 (R2 is generally compatible with the S3 API, but they haven't yet implemented every endpoint). This should be the case when both deleting an existing image, or replacing it.

Another perhaps related issue is that the "Asset indexes" update will prompt you to delete all the files from R2 -- it doesn't seem to be able to find them in the remote filesystem? I also cannot restore them from the R2 filesystem back into the asset index this way.

Transforms are saved in "hidden" directories prefixed with an underscore, so these won't directly be picked up when updating Asset Indexes. They would need to be manually deleted (but should be deleted when deleting the asset itself, see above).

FreekVR commented 1 year ago

Turns out this was party due to #6 and due to my subfolder path being set to //some-folder which is apparently confusing R2 and created a second subfolder in some cases -- which then threw off the asset indexing in Craft too.

May also be causing the issues with assets, so closing this for now :)