[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sup-devel] [PATCH 2/2] {config, sources}.yaml: preserve symlinks and permissions



Excerpts from William Morgan's message of Wed Jan 19 12:19:11 -0500 2011:

> Actually, I think it should be:
> 
>   if File.exists?(fn) && File.size(fn) > 0

How about:

begin
   fninf = File.stat(fn)
   if fninf.size? ...

rescue Errno::ENOENT => e
...
end
       
I didn't look at the surrounding code so I'm not sure how to best
integrate this.  The advantage is that you save one user->kernel space
traversal.  Calling .exists? and .size via File results in two stat()
calls.  Grabbing and saving the actual stat result on the first call
and then using them for further tests saves this.  Not a huge
overhead, I admit...

HTH.
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel