]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-new.c
Send mail to notmuch list, not Carl
[notmuch] / notmuch-new.c
index 6405cf0e5502c97893a30c46a577bb9f89be855b..f58a384b52b1cf48cbb7067b2e5f8743e9b0aeae 100644 (file)
@@ -197,10 +197,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)) {