make_dir_hier(path);
filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(uid), NULL);
g_free(path);
-
+ debug_print("trying to fetch cached %s\n", filename);
if (is_file_exist(filename)) {
/* see whether the local file represents the whole message
* or not. As the IMAP server reports size with \r chars,
unlock_session();
return -1;
}
+ } else if (!(MSG_IS_QUEUED(*fileinfo->flags)
+ || MSG_IS_DRAFT(*fileinfo->flags))
+ && (folder_has_parent_of_type(dest, F_QUEUE)
+ || folder_has_parent_of_type(dest, F_DRAFT))) {
+ return -1;
}
}
if (real_file == NULL)
statusbar_progress_all(0,0,0);
statusbar_pop_all();
return -1;
+ } else {
+ debug_print("appended new message as %d\n", new_uid);
+ /* put the local file in the imapcache, so that we don't
+ * have to fetch it back later. */
+ if (new_uid > 0) {
+ gchar *cache_path = folder_item_get_path(dest);
+ if (!is_dir_exist(cache_path))
+ make_dir_hier(cache_path);
+ if (is_dir_exist(cache_path)) {
+ gchar *cache_file = g_strconcat(
+ cache_path, G_DIR_SEPARATOR_S,
+ itos(new_uid), NULL);
+ copy_file(real_file, cache_file, TRUE);
+ debug_print("copied to cache: %s\n", cache_file);
+ g_free(cache_file);
+ }
+ g_free(cache_path);
+ }
}
if (relation != NULL)
statusbar_progress_all(0,0,0);
statusbar_pop_all();
+ imap_cmd_expunge(session);
unlock_session();
g_free(destdir);
msginfo = (MsgInfo *)msglist->data;
g_return_val_if_fail(msginfo->folder != NULL, -1);
+ /* if from/to are the same "type" (with or without extra headers),
+ * copy them via imap */
if (folder == msginfo->folder->folder &&
!folder_has_parent_of_type(msginfo->folder, F_DRAFT) &&
- !folder_has_parent_of_type(msginfo->folder, F_QUEUE)) {
+ !folder_has_parent_of_type(msginfo->folder, F_QUEUE) &&
+ !folder_has_parent_of_type(dest, F_DRAFT) &&
+ !folder_has_parent_of_type(dest, F_QUEUE)) {
+ ret = imap_do_copy_msgs(folder, dest, msglist, relation);
+ return ret;
+ } else if (folder == msginfo->folder->folder &&
+ (folder_has_parent_of_type(msginfo->folder, F_DRAFT) ||
+ folder_has_parent_of_type(msginfo->folder, F_QUEUE)) &&
+ (folder_has_parent_of_type(dest, F_DRAFT) ||
+ folder_has_parent_of_type(dest, F_QUEUE))) {
ret = imap_do_copy_msgs(folder, dest, msglist, relation);
return ret;
}
-
+ /* else reupload them */
file_list = procmsg_get_message_file_list(msglist);
g_return_val_if_fail(file_list != NULL, -1);
ret = imap_add_msgs(folder, dest, file_list, relation);
-
procmsg_message_file_list_free(file_list);
return ret;