mirror of
https://github.com/discourse/discourse.git
synced 2025-03-04 07:46:23 +08:00
FIX: Memoization in EmberCli ruby helper class (#24139)
Previously we were memoizing based on `defined?`, but the `clear_cache!` method was doing `@blah = nil`. That meant that after the cache was cleared, future calls to the memoized method would return `nil` instead of triggering a recalculation.
This commit is contained in:
parent
3f3d2ee2c0
commit
983fd04f4b
@ -6,11 +6,11 @@ module EmberCli
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.assets
|
def self.assets
|
||||||
@@assets ||= Dir.glob("**/*.{js,map,txt}", base: "#{dist_dir}/assets")
|
@assets ||= Dir.glob("**/*.{js,map,txt}", base: "#{dist_dir}/assets")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.script_chunks
|
def self.script_chunks
|
||||||
return @@chunk_infos if defined?(@@chunk_infos)
|
return @chunk_infos if @chunk_infos
|
||||||
|
|
||||||
chunk_infos = {}
|
chunk_infos = {}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ module EmberCli
|
|||||||
index_html = File.read("#{dist_dir}/index.html")
|
index_html = File.read("#{dist_dir}/index.html")
|
||||||
chunk_infos.merge! parse_chunks_from_html(index_html)
|
chunk_infos.merge! parse_chunks_from_html(index_html)
|
||||||
|
|
||||||
@@chunk_infos = chunk_infos if Rails.env.production?
|
@chunk_infos = chunk_infos if Rails.env.production?
|
||||||
chunk_infos
|
chunk_infos
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
{}
|
{}
|
||||||
@ -80,7 +80,7 @@ module EmberCli
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.clear_cache!
|
def self.clear_cache!
|
||||||
@@chunk_infos = nil
|
@chunk_infos = nil
|
||||||
@@assets = nil
|
@assets = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user