diff options
author | Carl Worth <cworth@cworth.org> | 2010-01-06 13:26:47 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-01-06 13:26:47 -0800 |
commit | 59c09623c844f095c14400a9b4199be20e5d712e (patch) | |
tree | 345fecc09112b5ccd707894332343b69ab75934e /notmuch-new.c | |
parent | 39e81ca431906370d0fee351419e1314e57a7c58 (diff) |
notmuch new: Fix to detect deletions of names at the end of the list.
Previously we only scanned the list of filenames in the filesystem and
detected a deletion whenever that scan skipped a name that existed in
the database. That much was fine, but we *also* need to continue
walking the list of names from the database when the filesystem list
is exhausted.
Without this, removing the last file or directory within any
particular directory would go undetected.
Diffstat (limited to 'notmuch-new.c')
-rw-r--r-- | notmuch-new.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/notmuch-new.c b/notmuch-new.c index 432d1262..f0c306d5 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -430,6 +430,30 @@ add_files_recursive (notmuch_database_t *notmuch, next = NULL; } + /* Now that we've walked the whole filesystem list, anything left + * over in the database lists has been deleted. */ + while (notmuch_filenames_has_more (db_files)) + { + char *absolute = talloc_asprintf (state->removed_files, + "%s/%s", path, + notmuch_filenames_get (db_files)); + + _filename_list_add (state->removed_files, absolute); + + notmuch_filenames_advance (db_files); + } + + while (notmuch_filenames_has_more (db_subdirs)) + { + char *absolute = talloc_asprintf (state->removed_directories, + "%s/%s", path, + notmuch_filenames_get (db_subdirs)); + + _filename_list_add (state->removed_directories, absolute); + + notmuch_filenames_advance (db_subdirs); + } + if (! interrupted) { status = notmuch_directory_set_mtime (directory, fs_mtime); if (status && ret == NOTMUCH_STATUS_SUCCESS) |