Fix cache-marshalling errors on Windows.
On Windows, if a file is opened as text and then passed to Marshal.load the call will fail if input has been read, per this thread: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/96123 . This change opens the cache files in binary mode. After that change marshalling wouldn't load the file correctly. I fixed this problem by opening the file for binary when writing the cache file.
This commit is contained in:
parent
8486d6db56
commit
0878919523
|
@ -91,7 +91,7 @@ module Sass
|
|||
def try_to_read_sassc(filename, compiled_filename, sha)
|
||||
return unless File.readable?(compiled_filename)
|
||||
|
||||
File.open(compiled_filename) do |f|
|
||||
File.open(compiled_filename, "rb") do |f|
|
||||
return unless f.readline("\n").strip == Sass::VERSION
|
||||
return unless f.readline("\n").strip == sha
|
||||
return Marshal.load(f.read)
|
||||
|
@ -106,7 +106,7 @@ module Sass
|
|||
return if File.exists?(File.dirname(compiled_filename)) && !File.writable?(File.dirname(compiled_filename))
|
||||
return if File.exists?(compiled_filename) && !File.writable?(compiled_filename)
|
||||
FileUtils.mkdir_p(File.dirname(compiled_filename))
|
||||
File.open(compiled_filename, "w") do |f|
|
||||
File.open(compiled_filename, "wb") do |f|
|
||||
f.write(Sass::VERSION)
|
||||
f.write("\n")
|
||||
f.write(sha)
|
||||
|
|
Loading…
Reference in New Issue