From: Chris Wilson <chris@chris-wilson.co.uk>
To: notmuch@notmuchmail.org
Subject: [PATCH] notmuch-new: Check for non-fatal errors from stat()
Date: Fri, 27 Nov 2009 13:50:11 +0000 [thread overview]
Message-ID: <1259329811-6393-1-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <87einkqeyt.fsf@yoom.home.cworth.org>
Currently we assume that all errors on stat() a dname is fatal (but
continue anyway and report the error at the end). However, some errors
reported by stat() such as a missing file or insufficient privilege,
we can simply ignore and skip the file. For the others, such as a fault
(unlikely!) or out-of-memory, we handle like the other fatal errors by
jumping to the end.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
notmuch-new.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/notmuch-new.c b/notmuch-new.c
index 3cde3a7..71224c5 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -168,10 +168,21 @@ add_files_recursive (notmuch_database_t *notmuch,
next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
if (stat (next, st)) {
+ int err = errno;
+
+ switch (err) {
+ case ENOENT:
+ /* The file was removed between scandir and now... */
+ case EPERM:
+ case EACCES:
+ /* We can't read this file so don't add it to the cache. */
+ continue;
+ }
+
fprintf (stderr, "Error reading %s: %s\n",
next, strerror (errno));
ret = NOTMUCH_STATUS_FILE_ERROR;
- continue;
+ goto DONE;
}
if (S_ISREG (st->st_mode)) {
--
1.6.5.3
next prev parent reply other threads:[~2009-11-27 13:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-22 0:57 [PATCH] notmuch-new: Eliminate tallocs whilst construct filenames Chris Wilson
2009-11-27 13:23 ` Carl Worth
2009-11-27 13:50 ` Chris Wilson [this message]
2009-11-28 5:37 ` [PATCH] notmuch-new: Check for non-fatal errors from stat() Carl Worth
2009-11-27 14:17 ` [PATCH] notmuch-new: Eliminate tallocs whilst construct filenames Chris Wilson
2009-11-28 5:41 ` Carl Worth
2009-11-28 5:58 ` Jeffrey Ollie
2009-11-28 17:38 ` Archiving outgoing email in Gnus (was Re: notmuch-new: Eliminate tallocs whilst construct filenames.) Adam Sjøgren
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
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1259329811-6393-1-git-send-email-chris@chris-wilson.co.uk \
--to=chris@chris-wilson.co.uk \
--cc=notmuch@notmuchmail.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.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).