From 2d531753b8d572f4c5a358dae6c3f8935ce7433f Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 14 May 2018 11:51:13 +0200 Subject: [PATCH] Bug 795977 - AutoArchive archives Junk and Deleted messages too --- src/mail/em-utils.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mail/em-utils.c b/src/mail/em-utils.c index 0f604bdbdf..fd39154e41 100644 --- a/src/mail/em-utils.c +++ b/src/mail/em-utils.c @@ -1803,12 +1803,16 @@ em_utils_process_autoarchive_sync (EMailBackend *mail_backend, g_date_time_unref (now_time); - search_sexp = g_strdup_printf ("(match-all (< (get-sent-date) %" G_GINT64_FORMAT "))", g_date_time_to_unix (use_time)); + search_sexp = g_strdup_printf ("(match-all (and " + "(not (system-flag \"junk\")) " + "(not (system-flag \"deleted\")) " + "(< (get-sent-date) %" G_GINT64_FORMAT ")" + "))", g_date_time_to_unix (use_time)); uids = camel_folder_search_by_expression (folder, search_sexp, cancellable, error); if (!uids) { success = FALSE; - } else { + } else if (uids->len > 0) { gint ii; if (aa_config == E_AUTO_ARCHIVE_CONFIG_MOVE_TO_ARCHIVE || @@ -1863,9 +1867,10 @@ em_utils_process_autoarchive_sync (EMailBackend *mail_backend, camel_folder_thaw (folder); } + } + if (uids) camel_folder_search_free (folder, uids); - } g_free (search_sexp); g_free (aa_custom_target_folder_uri); -- 2.11.4.GIT