зеркало из https://github.com/github/ruby.git
* 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:
Родитель
250d10b21f
Коммит
b8f3ef6136
|
@ -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>
|
||||
|
||||
* lib/tempfile.rb (Tempfile::MAX_TRY): remove unused constant.
|
||||
|
|
|
@ -140,10 +140,8 @@ class Tempfile < DelegateClass(File)
|
|||
else
|
||||
opts = perm
|
||||
end
|
||||
self.class.locking(tmpname) do
|
||||
@data[1] = @tmpfile = File.open(tmpname, mode, opts)
|
||||
@data[0] = @tmpname = tmpname
|
||||
end
|
||||
@mode = mode & ~(File::CREAT|File::EXCL)
|
||||
perm or opts.freeze
|
||||
@opts = opts
|
||||
|
@ -320,26 +318,6 @@ class Tempfile < DelegateClass(File)
|
|||
tempfile
|
||||
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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче