From: Ben Walton <bwalton@artsci.utoronto.ca>
To: sup-devel <sup-devel@rubyforge.org>
Subject: Re: [sup-devel] [PATCH 2/2] {config, sources}.yaml: preserve symlinks and permissions
Date: Wed, 19 Jan 2011 13:41:21 -0500 [thread overview]
Message-ID: <1295462152-sup-1745@pinkfloyd.chass.utoronto.ca> (raw)
In-Reply-To: <1295457514-sup-3702@masanjin.net>
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
prev parent reply other threads:[~2011-01-19 18:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-18 18:28 [sup-devel] [PATCH 1/2] ensure sources.yaml gets flushed to disk Sascha Silbe
2011-01-18 18:28 ` [sup-devel] [PATCH 2/2] {config, sources}.yaml: preserve symlinks and permissions Sascha Silbe
2011-01-19 3:41 ` Rich Lane
2011-01-19 10:05 ` Sascha Silbe
2011-01-19 15:38 ` William Morgan
2011-01-19 16:42 ` Sascha Silbe
2011-01-19 17:17 ` William Morgan
2011-01-19 18:44 ` Rich Lane
2011-01-19 17:19 ` William Morgan
2011-01-19 18:41 ` Ben Walton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1295462152-sup-1745@pinkfloyd.chass.utoronto.ca \
--to=bwalton@artsci.utoronto.ca \
--cc=sup-devel@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox