noent exception crashes page for assets that are missing
danielocallaghan opened this issue · comments
Hi,
For our app we have an nfs share only available in prod storing things like user avatars etc, in dev mode when using asset fingerprinting I had to add the following patch to avoid a page crash:
http://cl.ly/219fab591c55c1e20181
Think it was caused by at line similar to: File.read(absolute_path_to_file)
If you could add some sort of check that the file exists before attempting to fingerprint the asset that should help avoid this.
Great plugin btw!
Hi, thanks for the feedback and the kind words.
Currently I won't be able to use the code given, it can potentially mask other problems.
Please help by providing more detail on your situation.
Thanks, Eliot
quite right, this is a better/lower level patch that should show the problem I encountered pretty clearly:
So without that check for the actual existence of the asset file the whole page crashes rather than degrading more gracefully with a 404 for the asset.
Thanks for the patch Daniel, I think I understand your use case better and the behaviour you expect. Is what I've written below correct?
In development only, you are using paths to assets that don't exist on the filesystem (as they are only in production).
For these assets, regardless of environment (production, test, dev, etc.), you want:
- the asset path to be returned unmodified (i.e. without a fingerprint), so /image/missing-asset.png would remain intact and NOT /image/missing-asset-fp-[md5sum here].png
- no error to be raised
- a 404 returned for the asset
yup that sounds right.
Thanks
Thanks Daniel, have now fixed, contribution much appreciated!