mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 15:21:41 +01:00
notmuch-new: Check for non-fatal errors from stat()
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>
This commit is contained in:
parent
f94146bd39
commit
de064f1772
1 changed files with 12 additions and 1 deletions
|
@ -197,10 +197,21 @@ add_files_recursive (notmuch_database_t *notmuch,
|
||||||
next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
|
next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
|
||||||
|
|
||||||
if (stat (next, st)) {
|
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",
|
fprintf (stderr, "Error reading %s: %s\n",
|
||||||
next, strerror (errno));
|
next, strerror (errno));
|
||||||
ret = NOTMUCH_STATUS_FILE_ERROR;
|
ret = NOTMUCH_STATUS_FILE_ERROR;
|
||||||
continue;
|
goto DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISREG (st->st_mode)) {
|
if (S_ISREG (st->st_mode)) {
|
||||||
|
|
Loading…
Reference in a new issue