Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disappearing Images #30

Open
ryanbadger opened this issue Nov 16, 2016 · 3 comments
Open

Disappearing Images #30

ryanbadger opened this issue Nov 16, 2016 · 3 comments

Comments

@ryanbadger
Copy link

ryanbadger commented Nov 16, 2016

I'm not sure if anybody else has had this issue, but for me, as soon as my EC2 instance rebooted or scaled, images were lost.

I tracked it down to line 122 of CloudImage, the getFormattedImage function (Worth also adding to the doc that this ONLY works with that perhaps? E.G - CroppedImage etc all just fall back to standard Image.)

So that line seems to check if the file exists locally before doing anything else, which in most cases, it doesn't.

    if ($this->ID && $this->Filename && Director::fileExists($this->Filename)) {

I changed that to

    if ($this->ID && $this->Filename)) {

and now this works fine for me. As soon as I clear my assets folder on disk, it downloads every item again from S3, then resamples them and stores them correctly.

@markguinn
Copy link
Owner

Brilliant. Any chance you'd be willing to submit that as a PR?

@ryanbadger
Copy link
Author

ryanbadger commented Nov 16, 2016

Sure, but it may be better to add a better check here instead, I wrote an old S3 module for SS2.4 which checked the headers were 200 on S3 files before trying to use them, might be worth adding that in here too?

Ah actually, it looks like you already check for missing remote image further down anyway, so probably fine as it is. Will create a PR now, can you grant me access?

@ryanbadger
Copy link
Author

Another issue I saw was that when my app auto scales or I deploy, the cached images are of course lost, but the DB CloudImageCachedStore still tells SilverStripe they exist, so they aren't regenerated.

I'm sure a quick check in the code for file_exists would fix this, but as a hack I just run a post deploy script on my app to do a flush=all

And that clears the cache whenever I deploy to my site, or it autoscales.
Not sure if this will work when there are more than 1 instance running at once... but it's better than nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants