From: Joel VanderWerf Date: 2009-02-06T07:06:29+09:00 Subject: Re: File.delete one-liner Robert Klemme wrote: > On 05.02.2009 18:49, Joel VanderWerf wrote: >> Robert Klemme wrote: >>> 2009/2/4 Julian Leviston : >>>> File.delete(File.exists?(lockfile) ? lockfile : @lockfile) >>> [lockfile, @lockfile].any? {|f| File.delete(f) rescue false} >> >> If #delete fails on lockfile for some reason other than ENOENT, this >> code will try to delete @lockfile. > > This is correct. I thought that was intended. Didn't you suggest > exactly this in your previous posting (atomic deletion)? Looking at the > original question it is not clear in which cases @lockfile should be > deleted - unless you take the code as spec. > > Thanks for pointing this out! The only difference in my suggestion was to "Rescue Errno::ENOENT", which seems closer to the original intent of using #exists?... begin File.delete(lf) rescue Errno::ENOENT File.delete(@lf) end -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407