mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 10:58:10 +01:00
insert: respect maildir.synchronize_flags
Don't synchronize maildir flags if the user doesn't want it.
This commit is contained in:
parent
b00a62b3d9
commit
58dfc87721
2 changed files with 16 additions and 9 deletions
|
@ -295,7 +295,7 @@ copy_stdin (int fdin, int fdout)
|
||||||
* The file is renamed to encode notmuch tags as maildir flags. */
|
* The file is renamed to encode notmuch tags as maildir flags. */
|
||||||
static void
|
static void
|
||||||
add_file_to_database (notmuch_database_t *notmuch, const char *path,
|
add_file_to_database (notmuch_database_t *notmuch, const char *path,
|
||||||
tag_op_list_t *tag_ops)
|
tag_op_list_t *tag_ops, notmuch_bool_t synchronize_flags)
|
||||||
{
|
{
|
||||||
notmuch_message_t *message;
|
notmuch_message_t *message;
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
|
@ -323,11 +323,15 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path,
|
||||||
|
|
||||||
if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
|
if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
|
||||||
/* Don't change tags of an existing message. */
|
/* Don't change tags of an existing message. */
|
||||||
|
if (synchronize_flags) {
|
||||||
status = notmuch_message_tags_to_maildir_flags (message);
|
status = notmuch_message_tags_to_maildir_flags (message);
|
||||||
if (status != NOTMUCH_STATUS_SUCCESS)
|
if (status != NOTMUCH_STATUS_SUCCESS)
|
||||||
fprintf (stderr, "Error: failed to sync tags to maildir flags\n");
|
fprintf (stderr, "Error: failed to sync tags to maildir flags\n");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tag_op_list_apply (message, tag_ops, TAG_FLAG_MAILDIR_SYNC);
|
tag_op_flag_t flags = synchronize_flags ? TAG_FLAG_MAILDIR_SYNC : 0;
|
||||||
|
|
||||||
|
tag_op_list_apply (message, tag_ops, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_message_destroy (message);
|
notmuch_message_destroy (message);
|
||||||
|
@ -335,7 +339,8 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path,
|
||||||
|
|
||||||
static notmuch_bool_t
|
static notmuch_bool_t
|
||||||
insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
|
insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
|
||||||
const char *dir, tag_op_list_t *tag_ops)
|
const char *dir, tag_op_list_t *tag_ops,
|
||||||
|
notmuch_bool_t synchronize_flags)
|
||||||
{
|
{
|
||||||
char *tmppath;
|
char *tmppath;
|
||||||
char *newpath;
|
char *newpath;
|
||||||
|
@ -377,7 +382,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
|
||||||
|
|
||||||
/* Even if adding the message to the notmuch database fails,
|
/* Even if adding the message to the notmuch database fails,
|
||||||
* the message is on disk and we consider the delivery completed. */
|
* the message is on disk and we consider the delivery completed. */
|
||||||
add_file_to_database (notmuch, newpath, tag_ops);
|
add_file_to_database (notmuch, newpath, tag_ops, synchronize_flags);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -400,6 +405,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
char *query_string = NULL;
|
char *query_string = NULL;
|
||||||
const char *folder = NULL;
|
const char *folder = NULL;
|
||||||
notmuch_bool_t create_folder = FALSE;
|
notmuch_bool_t create_folder = FALSE;
|
||||||
|
notmuch_bool_t synchronize_flags;
|
||||||
const char *maildir;
|
const char *maildir;
|
||||||
int opt_index;
|
int opt_index;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -420,6 +426,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
|
|
||||||
db_path = notmuch_config_get_database_path (config);
|
db_path = notmuch_config_get_database_path (config);
|
||||||
new_tags = notmuch_config_get_new_tags (config, &new_tags_length);
|
new_tags = notmuch_config_get_new_tags (config, &new_tags_length);
|
||||||
|
synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
|
||||||
|
|
||||||
tag_ops = tag_op_list_create (config);
|
tag_ops = tag_op_list_create (config);
|
||||||
if (tag_ops == NULL) {
|
if (tag_ops == NULL) {
|
||||||
|
@ -471,7 +478,8 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
|
NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops);
|
ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops,
|
||||||
|
synchronize_flags);
|
||||||
|
|
||||||
notmuch_database_destroy (notmuch);
|
notmuch_database_destroy (notmuch);
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,6 @@ dirname=$(dirname "$output")
|
||||||
test_expect_equal "$dirname" "$MAIL_DIR/cur"
|
test_expect_equal "$dirname" "$MAIL_DIR/cur"
|
||||||
|
|
||||||
test_begin_subtest "Insert message with maildir sync off goes to new/"
|
test_begin_subtest "Insert message with maildir sync off goes to new/"
|
||||||
test_subtest_known_broken
|
|
||||||
OLDCONFIG=$(notmuch config get maildir.synchronize_flags)
|
OLDCONFIG=$(notmuch config get maildir.synchronize_flags)
|
||||||
notmuch config set maildir.synchronize_flags false
|
notmuch config set maildir.synchronize_flags false
|
||||||
gen_insert_msg
|
gen_insert_msg
|
||||||
|
|
Loading…
Reference in a new issue