PStore bug and verify

e$B@.@%$G$9!#e(B

e$B$^$:!“e(Bpstore.rb e$B$Ge(B binary mode e$B$X$N$7K:$l$,$”$j$^$9!#e(B
diff -u -r1.27 pstore.rb
— pstore.rb 5 Feb 2006 05:28:11 -0000 1.27
+++ pstore.rb 7 Sep 2006 02:28:40 -0000
@@ -297,7 +297,14 @@
file = File.open(@filename, File::RDONLY)
file.binmode
file.flock(File::LOCK_SH)

  •      content = (File.read(new_file) rescue file.read())
    
  •      begin
    
  •        File.open(new_file, "r") {|n|
    
  •          n.binmode
    
  •          content = n.read
    
  •        }
    
  •     rescue
    
  •        content = file.read()
    
  •     end
       rescue Errno::ENOENT
         content = ""
       end
    

e$B9T?t$,A}$($F$7$^$C$FHa$7$$%Q%C%A$J$N$G$9$,!"e(B
[ruby-dev:28720] e$B$Ne(B IO.read e$B$NOC$O?JE8$J$7$G$9$+!)e(B

e$B$5$F!"K?$A$c$s$M$k$Ge(B PStore e$B$,OCBj$K$J$C$F$$$^$9$,!"e(B

f.binmode e$B$,8z$+$J$$!)e(B

http://pc8.2ch.net/test/read.cgi/tech/1147935007/81

e$B0JA0$+$ie(B PStore
e$B$O?.Mj@-$,$$$^$$$A$H$$$&OC$r7QB3E*$KJ9$-$^$9$7!“e(B
e$B%G!<%?$,2u$l$?7P83$b2?EY$+$”$j$^$9!#e(B

e$B$=$3$G!"$A$c$s$H=q$-9~$a$?$+3NG’$9$k$h$&$K$7$^$;$s$+!#e(B
e$B:#2s$N7o$J$i$P!"e(B
diff -u -r1.27 pstore.rb
— pstore.rb 5 Feb 2006 05:28:11 -0000 1.27
+++ pstore.rb 7 Sep 2006 02:22:58 -0000
@@ -330,6 +330,10 @@
t.binmode
t.write(content)
}

  •        File.open(tmp_file, "r") {|t|
    
  •          t.binmode
    
  •          raise unless md5 == Digest::MD5.digest(t.read)
    
  •        }
           File.rename(tmp_file, new_file)
           commit_new(file)
         end
    

e$B$G!"?7$?$J%G!<%?$O<:$C$F$b!"4{B8$N%G!<%?$O0];}$G$-$k$+$J$H!#e(B

e$B$^$?!"2?%P%$%H$+$4$H$Ke(B chksum e$B$D$1$k$H$+!"e(B
e$B2?$i$+$N%(%i!<D{@5Id9f$r$D$1$i$l$k$H$@$$$V?.Mj@-$,>e$,$k$H;W$&$N$G$9$,!#e(B

e$B$J$+$@$G$9!#e(B

At Thu, 7 Sep 2006 11:33:43 +0900,
NARUSE Yui wrote in [ruby-dev:29518]:

  •      content = (File.read(new_file) rescue file.read())
    

e$B9T?t$,A}$($F$7$^$C$FHa$7$$%Q%C%A$J$N$G$9$,!"e(B

  •      content = (File.open(new_file, "rt") {|n| n.read} rescue
    

file.read())

e$B$5$F!"K?$A$c$s$M$k$Ge(B PStore e$B$,OCBj$K$J$C$F$$$^$9$,!"e(B

f.binmode e$B$,8z$+$J$$!)e(B

http://pc8.2ch.net/test/read.cgi/tech/1147935007/81

e$B$?$7$+e(Bmsvcrte$B$Ne(Bopen()e$B$,!"e(BO_TEXT+O_RDWRe$B$@$H:G=i$KKvHx$Ne(BCtrl-Ze$B$r:o$C$F$?e(B
e$B$O$:$G$9!#$@$+$i$=$N8e$G$+$($F$b8e$N:W$j!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29519] Re: PStore bug and verify”
on Thu, 7 Sep 2006 14:06:16 +0900, “Nobuyoshi N.”
[email protected] writes:
|NARUSE Yui wrote in [ruby-dev:29518]:
|> - content = (File.read(new_file) rescue file.read())
|
|> e$B9T?t$,A}$($F$7$^$C$FHa$7$$%Q%C%A$J$N$G$9$,!"e(B
|
| + content = (File.open(new_file, “rt”) {|n| n.read} rescue
|file.read())

e$B%3%_%C%H$7$F$/$@$5$$e(B(e$B$G$be(B"rt"e$B$8$c$J$/$Fe(B"rb"e$B$8$c$J$$$+$He(B)e$B!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29518] PStore bug and verify”
on Thu, 7 Sep 2006 11:33:43 +0900, NARUSE Yui [email protected]
writes:

|e$B$^$:!“e(Bpstore.rb e$B$Ge(B binary mode e$B$X$N$7K:$l$,$”$j$^$9!#e(B

e$B$J$+$@$5$s$K%Q%C%A$r0MMj$7$^$7$?!#e(B

|[ruby-dev:28720] e$B$Ne(B IO.read e$B$NOC$O?JE8$J$7$G$9$+!)e(B

e$B$=$&$G$9$M!#e(B

|e$B$=$3$G!"$A$c$s$H=q$-9~$a$?$+3NG’$9$k$h$&$K$7$^$;$s$+!#e(B

e$B$&!<$`!"$^$9$^$9CY$/$J$j$=$&$G$9!#e(B

|e$B$^$?!"2?%P%$%H$+$4$H$Ke(B chksum e$B$D$1$k$H$+!"e(B
|e$B2?$i$+$N%(%i!<D{@5Id9f$r$D$1$i$l$k$H$@$$$V?.Mj@-$,>e$,$k$H;W$&$N$G$9$,!#e(B

Marshale$B$N%U%)!<%^%C%HJQ99$K$J$j$^$9$M!#$^$“!”$I$&$;e(B1.9e$B$O6a$$e(B
e$B>-MhJQ99$,I,MW$J$N$Ge(B(M17Ne$B$H$+e(B)e$B!"$=$N;~$K0l=o$KJQ99$9$k$N$O%"e(B
e$B%j$@$H;W$$$^$9!#$I$J$?$+$=$NJU$,F@0U$JJ}$,$$$i$C$7$c$l$P6(NOe(B
e$B$7$F$$$?$@$-$?$$$N$G$9$,e(B(e$B;d$O6l<je(B)e$B!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)