+ removed_files = 0;
+ renamed_files = 0;
+ for (f = add_files_state.removed_files->head; f; f = f->next) {
+ status = notmuch_database_remove_message (notmuch, f->filename);
+ if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)
+ renamed_files++;
+ else
+ removed_files++;
+ }
+
+ for (f = add_files_state.removed_directories->head; f; f = f->next) {
+ notmuch_directory_t *directory;
+ notmuch_filenames_t *files;
+
+ directory = notmuch_database_get_directory (notmuch, f->filename);
+
+ for (files = notmuch_directory_get_child_files (directory);
+ notmuch_filenames_has_more (files);
+ notmuch_filenames_advance (files))
+ {
+ char *absolute;
+
+ absolute = talloc_asprintf (ctx, "%s/%s", f->filename,
+ notmuch_filenames_get (files));
+ status = notmuch_database_remove_message (notmuch, absolute);
+ if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)
+ renamed_files++;
+ else
+ removed_files++;
+ talloc_free (absolute);
+ }
+
+ notmuch_directory_destroy (directory);
+ }
+
+ talloc_free (add_files_state.removed_files);
+ talloc_free (add_files_state.removed_directories);
+