-
Notifications
You must be signed in to change notification settings - Fork 244
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
Check if Dragonfly file exists before fetching it #350
Comments
hi - the problem with adding #exists? is that this will need to be added to the spec for datastores, which is currently very simple (read, write and destroy). |
We are storing:
|
As seen above we first upload the file to the rails server if the form is validated we try to send it to the Backend. But after this upload an error can still occur with other data and this will perform return render :index. When the user tries to submit the page again the same code will be launched since @cached_files is still present as before only difference is that the file doesn't exist anymore on the server because we deleted it in the previous run. @markevans to answer the question even more since the @cached_files exist the UID is still in them. So actually we try to retrieve file and send it to the backend but it doesn't exist. So it would be awesome if I was able to check if the file still exists before trying fetching a file that doesn't exist. |
I don't want to add this to the datastore spec, however it could be added to an individual datastore, e.g. |
I'm retrieving the Dragonfly file with
Dragonfly[:images].fetch(uid)
but if I already deleted the file I'm gettingDragonfly::DataStorage::DataNotFound
which is logical because I'm trying to fetch a file that is deleted.The file is automatically deleted when send to the Backend, but if an error occurs somewhere while processing the form I return to index and the system will try to upload it again.
So I'm currently fixing it like this:
But it would be better if I could do something like this
The text was updated successfully, but these errors were encountered: