Skip to content

Commit 6a9bcb5

Browse files
committed
Fix mtime
See #197 (comment) for more information.
1 parent 3c94ce7 commit 6a9bcb5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/sprockets/utils/gzip.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ def cannot_compress?(mime_types)
4141
#
4242
# Returns nothing.
4343
def compress(target)
44+
mtime = PathUtils.stat(target).mtime
4445
PathUtils.atomic_write("#{target}.gz") do |f|
4546
gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
46-
gz.mtime = PathUtils.stat(target).mtime
47+
gz.mtime = mtime
4748
gz.write(@source)
4849
gz.close
50+
51+
File.utime(mtime, mtime, f.path)
4952
end
5053

5154
nil

test/test_manifest.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ def teardown
526526
original_path = @env[file_name].digest_path
527527
manifest.compile(file_name)
528528
assert File.exist?("#{@dir}/#{original_path}.gz"), "Expecting '#{original_path}' to generate gzipped file: '#{original_path}.gz' but it did not"
529-
assert_equal File.stat("#{@dir}/#{original_path}").mtime, Zlib::GzipReader.open("#{@dir}/#{original_path}.gz") {|gz| gz.mtime }
530529
end
531530
end
532531

0 commit comments

Comments
 (0)