mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/tempfile.rb: don't use lock directory. [ruby-dev:39197]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
250d10b21f
commit
b8f3ef6136
2 changed files with 6 additions and 24 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Dec 4 22:53:12 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/tempfile.rb: don't use lock directory. [ruby-dev:39197]
|
||||||
|
|
||||||
Sun Dec 4 22:34:43 2011 Tanaka Akira <akr@fsij.org>
|
Sun Dec 4 22:34:43 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* lib/tempfile.rb (Tempfile::MAX_TRY): remove unused constant.
|
* lib/tempfile.rb (Tempfile::MAX_TRY): remove unused constant.
|
||||||
|
|
|
@ -140,10 +140,8 @@ class Tempfile < DelegateClass(File)
|
||||||
else
|
else
|
||||||
opts = perm
|
opts = perm
|
||||||
end
|
end
|
||||||
self.class.locking(tmpname) do
|
@data[1] = @tmpfile = File.open(tmpname, mode, opts)
|
||||||
@data[1] = @tmpfile = File.open(tmpname, mode, opts)
|
@data[0] = @tmpname = tmpname
|
||||||
@data[0] = @tmpname = tmpname
|
|
||||||
end
|
|
||||||
@mode = mode & ~(File::CREAT|File::EXCL)
|
@mode = mode & ~(File::CREAT|File::EXCL)
|
||||||
perm or opts.freeze
|
perm or opts.freeze
|
||||||
@opts = opts
|
@opts = opts
|
||||||
|
@ -320,26 +318,6 @@ class Tempfile < DelegateClass(File)
|
||||||
tempfile
|
tempfile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# :stopdoc:
|
|
||||||
|
|
||||||
# yields with locking for +tmpname+ and returns the result of the
|
|
||||||
# block.
|
|
||||||
def locking(tmpname)
|
|
||||||
lock = tmpname + '.lock'
|
|
||||||
mkdir(lock)
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
rmdir(lock) if lock
|
|
||||||
end
|
|
||||||
|
|
||||||
def mkdir(*args)
|
|
||||||
Dir.mkdir(*args)
|
|
||||||
end
|
|
||||||
|
|
||||||
def rmdir(*args)
|
|
||||||
Dir.rmdir(*args)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue