Skip to content

Commit

Permalink
Hash based on non-minified contents
Browse files Browse the repository at this point in the history
Minification is unlikely to change that often, and this means that there
is no need for runtime compiling which has potential thread safety
issues
  • Loading branch information
namelessjon committed Mar 30, 2012
1 parent 7089593 commit 15a04e0
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/sinatra/simple_assets/bundle.rb
Expand Up @@ -16,21 +16,15 @@ def name
end

def hash_name
"#{@name}-#{hash}.#{@type}"
"#{@name}-#{asset_hash}.#{@type}"
end

def hashed_path
"#{path}/#{hash_name}"
end

def hash
@hash ||= begin
Digest::SHA1.hexdigest content
rescue
# Find the most recent compressed version if the JS runtime is unavailable
fname = Dir.glob("#{@root}/#{path}/#{@name}-*.#{@type}").sort_by {|f| File.mtime(f)}.last
fname.split('-').last.sub(".#{@type}", "")
end
def asset_hash
@asset_hash ||= Digest::SHA1.hexdigest(combined)
end

def content
Expand Down

0 comments on commit 15a04e0

Please sign in to comment.