RSSyl: handle expiring comments after their parent is gone
[claws.git] / src / plugins / rssyl / rssyl_update_format.c
index 828445075e340150831fbb43b3d6a1eb7939a0f6..35fe172c75b49dc479b2713805be77b4e9c97031 100644 (file)
 
 /* Claws Mail includes */
 #include <alertpanel.h>
+#include <folder_item_prefs.h>
 #include <log.h>
 #include <mainwindow.h>
+#include <matcher.h>
+#include <msgcache.h>
 
 /* Local includes */
 #include "old_feeds.h"
@@ -149,7 +152,6 @@ static void rssyl_update_format_func(FolderItem *item, gpointer data)
 
                        rssyl_feed_start_refresh_timeout(ritem);
 
-                       /* TODO: copy feed preferences from old structure */
                        ritem->official_title = g_strdup(of->official_name);
                        ritem->default_refresh_interval =
                                (of->default_refresh_interval != 0 ? TRUE : FALSE);
@@ -159,10 +161,19 @@ static void rssyl_update_format_func(FolderItem *item, gpointer data)
                                (of->fetch_comments != 0 ? TRUE : FALSE);
                        ritem->fetch_comments_max_age = of->fetch_comments_for;
                        ritem->silent_update = of->silent_update;
+                       ritem->ssl_verify_peer = of->ssl_verify_peer;
+
+                       folder_item_prefs_copy_prefs(item, &ritem->item);
                }
 
                rssyl_update_format_move_contents(item, new_item);
 
+               /* destroy the new folder's cache so we'll re-read the migrated one */
+               if (new_item->cache) {
+                       msgcache_destroy(new_item->cache);
+                       new_item->cache = NULL;
+               }
+
                /* Store folderlist with the new folder */
                folder_item_scan(new_item);
                folder_write_list();
@@ -209,6 +220,9 @@ void rssyl_update_format()
        g_slist_foreach(ctx->oldroots, _delete_old_roots_func, NULL);
        g_slist_free(ctx->oldroots);
 
+       prefs_matcher_write_config();
+       folder_write_list();
+
        folder_item_update_thaw();
 
        g_free(ctx);
@@ -246,8 +260,9 @@ static void rssyl_update_format_move_contents(FolderItem *olditem,
                        oldpath, newpath);
 
        while ((fname = (gchar *)g_dir_read_name(d)) != NULL) {
+               gboolean migrate_file = to_number(fname) > 0 || strstr(fname, ".claws_") == fname;
                fpath = g_strconcat(oldpath, G_DIR_SEPARATOR_S, fname, NULL);
-               if (to_number(fname) > 0 && g_file_test(fpath, G_FILE_TEST_IS_REGULAR)) {
+               if (migrate_file && g_file_test(fpath, G_FILE_TEST_IS_REGULAR)) {
                        nfpath = g_strconcat(newpath, G_DIR_SEPARATOR_S, fname, NULL);
                        move_file(fpath, nfpath, FALSE);
                        g_free(nfpath);