Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
added a to_i when comparing times on asset, fidelity is already hard
Browse files Browse the repository at this point in the history
coded to 1 second in lots of other spots
change persistence format to Fixnum from String, upgrade should take
care of cleaning up tmp/cache directory
  • Loading branch information
SamSaffron committed Apr 9, 2013
1 parent 0c9582d commit 2fefbf4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/sprockets/asset.rb
Expand Up @@ -39,7 +39,8 @@ def initialize(environment, logical_path, pathname)
@logical_path = logical_path.to_s
@pathname = Pathname.new(pathname)
@content_type = environment.content_type_of(pathname)
@mtime = environment.stat(pathname).mtime
# drop precision to 1 second, same pattern followed elsewhere
@mtime = Time.at(environment.stat(pathname).mtime.to_i)
@length = environment.stat(pathname).size
@digest = environment.file_digest(pathname).hexdigest
end
Expand All @@ -58,8 +59,7 @@ def init_with(environment, coder)
end

if mtime = coder['mtime']
# Parse time string
@mtime = Time.parse(mtime)
@mtime = Time.at(mtime)
end

if length = coder['length']
Expand All @@ -74,7 +74,7 @@ def encode_with(coder)
coder['logical_path'] = logical_path
coder['pathname'] = relativize_root_path(pathname).to_s
coder['content_type'] = content_type
coder['mtime'] = mtime.iso8601
coder['mtime'] = mtime.to_i
coder['length'] = length
coder['digest'] = digest
end
Expand Down Expand Up @@ -244,7 +244,11 @@ def dependency_fresh?(environment, dep)
# stale. Many deployment environments may recopy or recheckout
# assets on each deploy. In this case the mtime would be the
# time of deploy rather than modified time.
if mtime >= stat.mtime
#
# Note: to_i is used in eql? and write_to we assume fidelity of 1 second
# if people save files more frequently than 1 second sprockets may
# not pick it up, by design
if mtime.to_i >= stat.mtime.to_i
return true
end

Expand Down

0 comments on commit 2fefbf4

Please sign in to comment.