aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-01-06 13:54:39 -0800
committerGravatar Carl Worth <cworth@cworth.org>2010-01-06 13:54:39 -0800
commit7d8271dd9db5affa9fce589424d6f3b4d8b66cd7 (patch)
tree00f1f35c75be6886385bc0b2b744402e4a163e7b
parent59c09623c844f095c14400a9b4199be20e5d712e (diff)
notmuch new: Fix bug resulting in file removal on initial build of database.
The bug here was that we would see that the database did not know anything about a directory so would get results from the filesystem in inode rather than strcmp order. However, we wouldn't actually ask for the list of files from the database until after recursing into the sub-directories. So by the time we traverse the filenames looking for deletions, the database *does* have entries and we end up detecting erroneous deletions because our filename list from the filesystem isn't in strcmp order. So ask for the list of names from the database before doing any additions to avoid this problem.
-rw-r--r--notmuch-new.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/notmuch-new.c b/notmuch-new.c
index f0c306d5..7d15fe91 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -239,6 +239,8 @@ add_files_recursive (notmuch_database_t *notmuch,
directory = notmuch_database_get_directory (notmuch, path);
db_mtime = notmuch_directory_get_mtime (directory);
+ db_files = notmuch_directory_get_child_files (directory);
+ db_subdirs = notmuch_directory_get_child_directories (directory);
/* If the database knows about this directory, then we sort based
* on strcmp to match the database sorting. Otherwise, we can do
@@ -294,9 +296,6 @@ add_files_recursive (notmuch_database_t *notmuch,
goto DONE;
/* Pass 2: Scan for new files, removed files, and removed directories. */
- db_files = notmuch_directory_get_child_files (directory);
- db_subdirs = notmuch_directory_get_child_directories (directory);
-
for (i = 0; i < num_fs_entries; i++)
{
if (interrupted)