aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-new.c
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-01-06 10:30:08 -0800
committerGravatar Carl Worth <cworth@cworth.org>2010-01-06 10:48:43 -0800
commit39e81ca431906370d0fee351419e1314e57a7c58 (patch)
treef7e2c82e77e260371d1f15e4fea9435d0d977be8 /notmuch-new.c
parent49f09958df22f80e4058b6f2892f6224a80c3d6d (diff)
notmuch new: Fix regression preventing addition of symlinked mail files.
As described in the previous commit message, we introduced multiple symlink-based regressions in commit 3df737bc4addfce71c647792ee668725e5221a98 Here, we fix the case of symlinks to regular files by doing an extra stat of any DT_LNK files to determine if they do, in fact, link to regular files.
Diffstat (limited to 'notmuch-new.c')
-rw-r--r--notmuch-new.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/notmuch-new.c b/notmuch-new.c
index e2b5878f..432d1262 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -334,8 +334,27 @@ add_files_recursive (notmuch_database_t *notmuch,
notmuch_filenames_advance (db_subdirs);
}
- if (entry->d_type != DT_REG)
+ /* If we're looking at a symlink, we only want to add it if it
+ * links to a regular file, (and not to a directory, say). */
+ if (entry->d_type == DT_LNK) {
+ int err;
+
+ next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
+ err = stat (next, &st);
+ talloc_free (next);
+ next = NULL;
+
+ /* Don't emit an error for a link pointing nowhere, since
+ * the directory-traversal pass will have already done
+ * that. */
+ if (err)
+ continue;
+
+ if (! S_ISREG (st.st_mode))
+ continue;
+ } else if (entry->d_type != DT_REG) {
continue;
+ }
/* Don't add a file that we've added before. */
if (notmuch_filenames_has_more (db_files) &&