mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/pstore.rb (PStore#transaction): get rid of opening in write mode
when read only transaction. [ruby-dev:23842] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7662d794fe
commit
73cf1d02ba
2 changed files with 10 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Jul 1 18:31:31 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/pstore.rb (PStore#transaction): get rid of opening in write mode
|
||||||
|
when read only transaction. [ruby-dev:23842]
|
||||||
|
|
||||||
Thu Jul 1 00:44:42 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
Thu Jul 1 00:44:42 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
* ext/openssl/ossl_cipher.c (ossl_cipher_encrypt, ossl_cipher_decrypt):
|
* ext/openssl/ossl_cipher.c (ossl_cipher_encrypt, ossl_cipher_decrypt):
|
||||||
|
|
|
@ -97,18 +97,15 @@ class PStore
|
||||||
new_file = @filename + ".new"
|
new_file = @filename + ".new"
|
||||||
|
|
||||||
content = nil
|
content = nil
|
||||||
file = File.open(@filename, File::RDWR | File::CREAT)
|
|
||||||
unless read_only
|
unless read_only
|
||||||
|
file = File.open(@filename, File::RDWR | File::CREAT)
|
||||||
file.flock(File::LOCK_EX)
|
file.flock(File::LOCK_EX)
|
||||||
commit_new(file) if FileTest.exist?(new_file)
|
commit_new(file) if FileTest.exist?(new_file)
|
||||||
content = file.read()
|
content = file.read()
|
||||||
else
|
else
|
||||||
|
file = File.open(@filename, File::RDONLY)
|
||||||
file.flock(File::LOCK_SH)
|
file.flock(File::LOCK_SH)
|
||||||
if FileTest.exist?(new_file)
|
content = (File.read(new_file) rescue file.read())
|
||||||
File.open(new_file) {|fp| content = fp.read()}
|
|
||||||
else
|
|
||||||
content = file.read()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if content != ""
|
if content != ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue