X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=notmuch-new.c;h=e2b5878f06058196f2e1826f681befbe32970641;hb=49f09958df22f80e4058b6f2892f6224a80c3d6d;hp=c15f6837218e21881df8b42e9bb4055afd0285a4;hpb=bd72d95bac894b3611bb4467e10c9481af0456bf;p=notmuch diff --git a/notmuch-new.c b/notmuch-new.c index c15f6837..e2b5878f 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -229,10 +229,11 @@ add_files_recursive (notmuch_database_t *notmuch, return NOTMUCH_STATUS_FILE_ERROR; } - if (! S_ISDIR (st.st_mode)) { - fprintf (stderr, "Error: %s is not a directory.\n", path); - return NOTMUCH_STATUS_FILE_ERROR; - } + /* This is not an error since we may have recursed based on a + * symlink to a regular file, not a directory, and we don't know + * that until this stat. */ + if (! S_ISDIR (st.st_mode)) + return NOTMUCH_STATUS_SUCCESS; fs_mtime = st.st_mtime; @@ -262,7 +263,7 @@ add_files_recursive (notmuch_database_t *notmuch, entry = fs_entries[i]; - if (entry->d_type != DT_DIR) + if (entry->d_type != DT_DIR && entry->d_type != DT_LNK) continue; /* Ignore special directories to avoid infinite recursion. @@ -447,6 +448,7 @@ add_files (notmuch_database_t *notmuch, struct sigaction action; struct itimerval timerval; notmuch_bool_t timer_is_active = FALSE; + struct stat st; if (state->output_is_a_tty && ! debugger_is_active () && ! state->verbose) { /* Setup our handler for SIGALRM */ @@ -466,6 +468,17 @@ add_files (notmuch_database_t *notmuch, timer_is_active = TRUE; } + if (stat (path, &st)) { + fprintf (stderr, "Error reading directory %s: %s\n", + path, strerror (errno)); + return NOTMUCH_STATUS_FILE_ERROR; + } + + if (! S_ISDIR (st.st_mode)) { + fprintf (stderr, "Error: %s is not a directory.\n", path); + return NOTMUCH_STATUS_FILE_ERROR; + } + status = add_files_recursive (notmuch, path, state); if (timer_is_active) {