Skip to content

Commit

Permalink
fixes rails#110 avoid race condition when clearing/using assets cache
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerlime committed Sep 17, 2022
1 parent 3903815 commit d5d57f6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/propshaft/load_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Propshaft::LoadPath
def initialize(paths = [], version: nil)
@paths = dedup(paths)
@version = version
@mutex ||= Mutex.new
end

def find(asset_name)
Expand Down Expand Up @@ -64,7 +65,10 @@ def without_dotfiles(files)
end

def clear_cache
@cached_assets_by_path = nil
@mutex.synchronize do
@cached_assets_by_path = nil
assets_by_path # seeds the cache
end
end

def dedup(paths)
Expand Down

0 comments on commit d5d57f6

Please sign in to comment.