Fix storing absolute path in cache (again) #547
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This bug shows up like this:
It looks like
logo.svg
does not exist, but it is definitely inapp/assets/images/
. You'll notice that the path is different in the error/tmp/dir_1
instead of/tmp/dir_2
in the backtrace. This is a caching bug that shows up when the project directory is compiled in a different path than the last time it was compiled. This happens on Heroku often since every build happens in a unique directory name.This bug was introduced in #441. In that PR the
to_load
andto_link
sets are used to store assets that will be loaded or linked. At the time of implementation it was thought that the key was removed in the Bundle processor before being stored in the cache. Unfortunately this is not the case as Sprockets pipelines are confusing and the Bundle processor gets called in the “self” pipeline which does not get called until after the “default” pipeline produces an asset that is stored to the cache.This PR fixes this issue by forcing the path into a relative path before being put in the cache, and then expanding from relative path after reading from cache.
I also added a test that should catch if any absolute values make their way into the cache, not just in the keys that we specify.