2007-05-02 [paul] 2.9.1cvs36
[claws.git] / src / folder.c
index bcc1f308f46cf729fa94ca790e9f981f916f5ebc..b2a17dc22256c13d1a6703dfcbd2cf03d3963542 100644 (file)
@@ -1779,6 +1779,7 @@ static gint syncronize_flags(FolderItem *item, MsgInfoList *msglist)
                MsgPermFlags permflags = 0;
                gboolean skip;
 
+               folder_item_update_freeze();
                for (cur = msglist; cur != NULL; cur = g_slist_next(cur)) {
                        msginfo = (MsgInfo *) cur->data;
                
@@ -1796,6 +1797,7 @@ static gint syncronize_flags(FolderItem *item, MsgInfoList *msglist)
                                        ~permflags & msginfo->flags.perm_flags, 0);
                        }
                }
+               folder_item_update_thaw();
        }
        folder_item_set_batch(item, FALSE);
        g_relation_destroy(relation);   
@@ -2525,7 +2527,11 @@ gchar *folder_item_fetch_msg_full(FolderItem *item, gint num, gboolean headers,
        if (folder->klass->fetch_msg_full == NULL)
                return folder_item_fetch_msg(item, num);
 
-       msgfile = folder->klass->fetch_msg_full(folder, item, num, 
+       if (item->prefs->offlinesync && prefs_common.real_time_sync)
+               msgfile = folder->klass->fetch_msg_full(folder, item, num, 
+                                               TRUE, TRUE);
+       else
+               msgfile = folder->klass->fetch_msg_full(folder, item, num, 
                                                headers, body);
 
        if (msgfile != NULL) {
@@ -3167,7 +3173,17 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour
                if (num >= 0) {
                        MsgInfo *newmsginfo = NULL;
 
-                       if (folderscan) {
+                       if (!folderscan && num > 0) {
+                               newmsginfo = get_msginfo(dest, num);
+                               if (newmsginfo != NULL) {
+                                       add_msginfo_to_cache(dest, newmsginfo, msginfo);
+                               }
+                       }
+                       if (newmsginfo == NULL) {
+                               if (!folderscan) {
+                                       folder_item_scan_full(dest, FALSE);
+                                       folderscan = TRUE;
+                               }
                                if (msginfo->msgid != NULL) {
                                        newmsginfo = folder_item_get_msginfo_by_msgid(dest, msginfo->msgid);
                                        if (newmsginfo != NULL) {
@@ -3175,11 +3191,6 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour
                                                num = newmsginfo->msgnum;
                                        }
                                }
-                       } else {
-                               newmsginfo = get_msginfo(dest, num);
-                               if (newmsginfo != NULL) {
-                                       add_msginfo_to_cache(dest, newmsginfo, msginfo);
-                               }
                        }
 
                        if (msginfo->planned_download 
@@ -3423,6 +3434,7 @@ static gchar *folder_item_get_cache_file(FolderItem *item)
 {
        gchar *path;
        gchar *file;
+       gchar *old_file;
 
        g_return_val_if_fail(item != NULL, NULL);
        g_return_val_if_fail(item->path != NULL, NULL);
@@ -3432,6 +3444,11 @@ static gchar *folder_item_get_cache_file(FolderItem *item)
        if (!is_dir_exist(path))
                make_dir_hier(path);
        file = g_strconcat(path, G_DIR_SEPARATOR_S, CACHE_FILE, NULL);
+       old_file = g_strconcat(path, G_DIR_SEPARATOR_S, OLD_CACHE_FILE, NULL);
+
+       if (!is_file_exist(file) && is_file_exist(old_file))
+               move_file(old_file, file, FALSE);
+       g_free(old_file);
        g_free(path);
 
        return file;
@@ -3441,6 +3458,7 @@ static gchar *folder_item_get_mark_file(FolderItem *item)
 {
        gchar *path;
        gchar *file;
+       gchar *old_file;
 
        g_return_val_if_fail(item != NULL, NULL);
        g_return_val_if_fail(item->path != NULL, NULL);
@@ -3450,6 +3468,11 @@ static gchar *folder_item_get_mark_file(FolderItem *item)
        if (!is_dir_exist(path))
                make_dir_hier(path);
        file = g_strconcat(path, G_DIR_SEPARATOR_S, MARK_FILE, NULL);
+       old_file = g_strconcat(path, G_DIR_SEPARATOR_S, OLD_MARK_FILE, NULL);
+
+       if (!is_file_exist(file) && is_file_exist(old_file))
+               move_file(old_file, file, FALSE);
+       g_free(old_file);
        g_free(path);
 
        return file;