mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-02-17 23:53:15 +01:00
new: Merge error checks from add_files and add_files_recursive
Previously, add_files_recursive could have been called on a symlink to a non-directory. Hence, calling it on a non-directory was not an error, so a separate function, add_files, existed to fail loudly in situations where the path had to be a directory. With the new stat-ing logic, add_files_recursive is always called on directories, so the separation of this logic is no longer necessary. Hence, this patch moves the strict error checking previously done by add_files into add_files_recursive.
This commit is contained in:
parent
d99270c450
commit
da170ee657
1 changed files with 5 additions and 22 deletions
|
@ -308,11 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch,
|
||||||
}
|
}
|
||||||
stat_time = time (NULL);
|
stat_time = time (NULL);
|
||||||
|
|
||||||
/* This is not an error since we may have recursed based on a
|
if (! S_ISDIR (st.st_mode)) {
|
||||||
* symlink to a regular file, not a directory, and we don't know
|
fprintf (stderr, "Error: %s is not a directory.\n", path);
|
||||||
* that until this stat. */
|
return NOTMUCH_STATUS_FILE_ERROR;
|
||||||
if (! S_ISDIR (st.st_mode))
|
}
|
||||||
return NOTMUCH_STATUS_SUCCESS;
|
|
||||||
|
|
||||||
fs_mtime = st.st_mtime;
|
fs_mtime = st.st_mtime;
|
||||||
|
|
||||||
|
@ -655,23 +654,7 @@ add_files (notmuch_database_t *notmuch,
|
||||||
const char *path,
|
const char *path,
|
||||||
add_files_state_t *state)
|
add_files_state_t *state)
|
||||||
{
|
{
|
||||||
notmuch_status_t status;
|
return add_files_recursive (notmuch, path, state);
|
||||||
struct stat st;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: This should be merged with the add_files function since it
|
/* XXX: This should be merged with the add_files function since it
|
||||||
|
|
Loading…
Add table
Reference in a new issue