X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-new.c;h=9d206167e997382d623934ce4dd1797751b2e950;hp=6405cf0e5502c97893a30c46a577bb9f89be855b;hb=4989ef3d871f2510dcf9cf65e7fddd81deeff82e;hpb=fb1a3452dac707f7f4dfb359452c102bfcd2c18f diff --git a/notmuch-new.c b/notmuch-new.c index 6405cf0e..9d206167 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -35,8 +35,10 @@ static volatile sig_atomic_t interrupted; static void handle_sigint (unused (int sig)) { + ssize_t ignored; static char msg[] = "Stopping... \n"; - write(2, msg, sizeof(msg)-1); + + ignored = write(2, msg, sizeof(msg)-1); interrupted = 1; } @@ -197,10 +199,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)) {