From: Henning Koch Date: 2004-10-05T19:15:06+09:00 Subject: Re: pstore.rb not operating in binmode Hi Matz, > |On Windows this causes PStore to corrupt the binary > |session data. > | > |I also posted about the issue to > |http://www.rubyonrails.org/show/MarshalDataTooShort > | > |The people in #rubyonrails asked me to post a note to > |ruby-talk about this issue. > > I have no machine that requires "binmode". Does this patch work for > you? Unfortunately it didn't. There are two more occasions of IO streams in the file, which also need to binmoded to make the issue go away. Here's my crude patch (I am rather illiterate of diff and CVS, I beg your pardon): --- pstore.rb 2004-10-05 11:52:51.965332800 +0200 +++ pstore.rb.unpatched 2004-07-03 04:38:31.000000000 +0200 @@ -99,13 +99,11 @@ content = nil unless read_only file = File.open(@filename, File::RDWR | File::CREAT) - file.binmode file.flock(File::LOCK_EX) commit_new(file) if FileTest.exist?(new_file) content = file.read() else file = File.open(@filename, File::RDONLY) - file.binmode file.flock(File::LOCK_SH) content = (File.read(new_file) rescue file.read()) end @@ -134,7 +132,6 @@ content = dump(@table) if !md5 || size != content.size || md5 != Digest::MD5.digest(content) File.open(tmp_file, "w") {|t| - t.binmode t.write(content) } File.rename(tmp_file, new_file) @@ -169,7 +166,6 @@ f.rewind new_file = @filename + ".new" File.open(new_file) do |nf| - nf.binmode FileUtils.copy_stream(nf, f) end File.unlink(new_file) - Henning -- Pretty Attractive Web Solutions http://www.paws.cx/