eliotsykes / asset_fingerprint

Asset Fingerprint Plugin for Ruby on Rails - allows you to use md5 or timestamps in query string or in asset filenames as suggested by Google Page Speed

Home Page:http://github.com/eliotsykes/asset_fingerprint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

http://pastie.org/1089819

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!