[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: pstore.rb not operating in binmode

Henning Koch

10/5/2004 10:15:00 AM

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/MarshalDa...
> |
> |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://ww...



1 Answer

Yukihiro Matsumoto

10/5/2004 1:01:00 PM

0

Hi,

In message "Re: pstore.rb not operating in binmode"
on Tue, 5 Oct 2004 19:15:06 +0900, "Henning Koch" <henning.koch@gmx.net> writes:

|> 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.

Thank you for the information. It will be fixed soon.

matz.