Skip to content

Commit

Permalink
Server should also sweep cache
Browse files Browse the repository at this point in the history
  • Loading branch information
brenogazzola committed Feb 4, 2025
1 parent 6a84a8c commit 60eb231
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
10 changes: 1 addition & 9 deletions lib/propshaft/load_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ def cache_sweeper
@cache_sweeper ||= begin
exts_to_watch = Mime::EXTENSION_LOOKUP.map(&:first)
files_to_watch = Array(paths).collect { |dir| [ dir.to_s, exts_to_watch ] }.to_h
mutex = Mutex.new

Rails.application.config.file_watcher.new([], files_to_watch) do
mutex.synchronize do
clear_cache
seed_cache
end
clear_cache
end
end
end
Expand Down Expand Up @@ -85,10 +81,6 @@ def clear_cache
@cached_asset_paths_by_glob = nil
end

def seed_cache
assets_by_path
end

def dedup(paths)
paths = Array(paths).map { |path| Pathname.new(path) }
deduped = [].tap do |deduped|
Expand Down
1 change: 1 addition & 0 deletions lib/propshaft/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def initialize(assembly)
end

def call(env)
Rails.application.assets.load_path.cache_sweeper.execute_if_updated
path, digest = extract_path_and_digest(env)

if (asset = @assembly.load_path.find(path)) && asset.fresh?(digest)
Expand Down

0 comments on commit 60eb231

Please sign in to comment.