mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-23 09:54:52 +01:00
notmuch new: Proper support for renamed and deleted files.
The "notmuch new" command will now efficiently notice if any files or directories have been removed from the mail store and will appropriately update its database. Any given mail message (as determined by the message ID) may have multiple corresponding filenames, and notmuch will return one of them. When a filen is deleted, the corresponding filename will be removed from the message in the database. When the last filename is removed from a message, that message will be entirely removed from the database. All file additions are handled before any file removals so that rename is supported properly.
This commit is contained in:
parent
2e96464f97
commit
3fa2385f7c
1 changed files with 19 additions and 2 deletions
|
@ -629,11 +629,28 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
|
||||||
ret = add_files (notmuch, db_path, &add_files_state);
|
ret = add_files (notmuch, db_path, &add_files_state);
|
||||||
|
|
||||||
for (f = add_files_state.removed_files->head; f; f = f->next) {
|
for (f = add_files_state.removed_files->head; f; f = f->next) {
|
||||||
printf ("Detected removed file: %s\n", f->filename);
|
notmuch_database_remove_message (notmuch, f->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (f = add_files_state.removed_directories->head; f; f = f->next) {
|
for (f = add_files_state.removed_directories->head; f; f = f->next) {
|
||||||
printf ("Detected removed directory: %s\n", f->filename);
|
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));
|
||||||
|
notmuch_database_remove_message (notmuch, absolute);
|
||||||
|
talloc_free (absolute);
|
||||||
|
}
|
||||||
|
|
||||||
|
notmuch_directory_destroy (directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
talloc_free (add_files_state.removed_files);
|
talloc_free (add_files_state.removed_files);
|
||||||
|
|
Loading…
Reference in a new issue