Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
**Master**

- Avoid recreating cache files removed during a read. [Oskar Eichler](https://github.com/OskarEichler)

Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md

# 4.4.1
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ Now in your `application.js` will correctly load the `foo.min.js` before `foo-ui

## Cache

A file cache read may finish after another process evicts that entry; updating its access time does not recreate an empty cache file.

Compiling assets is slow. It requires a lot of disk use to pull assets off of hard drives, a lot of RAM to manipulate those files in memory, and a lot of CPU for compilation operations. Because of this Sprockets has a cache to speed up asset compilation times. That's the good news. The bad news, is that sprockets has a cache and if you've found a bug it's likely going to involve the cache.

By default Sprockets uses the file system to cache assets. It makes sense that Sprockets does not want to generate assets that already exist on disk in `public/assets`, what might not be as intuitive is that Sprockets needs to cache "partial" assets.
Expand Down
6 changes: 5 additions & 1 deletion lib/sprockets/cache/file_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def get(key)
end

if value
FileUtils.touch(path)
begin
File.utime(nil, nil, path)
rescue Errno::ENOENT
# Another cache user may have removed the file after it was read.
end
value
end
end
Expand Down