* src/imap.c
authorChristoph Hohmann <reboot@gmx.ch>
Sat, 5 Oct 2002 13:02:50 +0000 (13:02 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sat, 5 Oct 2002 13:02:50 +0000 (13:02 +0000)
* src/news.c
* src/utils.c
* src/utils.h
        implement cache cleanups for claws' folder system

ChangeLog.claws
configure.in
src/imap.c
src/news.c
src/utils.c
src/utils.h

index 48d94b769af79fa79e15870cf3578bb1e88948d4..41104688fd8c4ae6d6ea2a4abcc0eaf3b3185fea 100644 (file)
@@ -1,3 +1,11 @@
+2002-10-05 [christoph] 0.8.3claws48
+
+       * src/imap.c
+       * src/news.c
+       * src/utils.c
+       * src/utils.h
+               implement cache cleanups for claws' folder system
+
 2002-10-05 [melvin]    0.8.3claws47
 
        * src/prefs_actions.c
index 2e878e6ff057a36e60dab22f810e198a910e6fdf..0285b232bf1caddcfeb283df0c2d1499042c8208 100644 (file)
@@ -10,7 +10,7 @@ MINOR_VERSION=8
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws47
+EXTRA_VERSION=claws48
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 7ae80f2dd9f91e17b210a64d284f3d572437bc5b..672e15ef93f0e842f06b6056596c73fb23f33a94 100644 (file)
@@ -3136,6 +3136,7 @@ GSList *imap_get_num_list(Folder *folder, FolderItem *_item)
        guint32 uid_validity = 0;
        GPtrArray *argbuf;
        gchar *cmdbuf = NULL;
+       gchar *dir;
        
        g_return_val_if_fail(folder != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
@@ -3183,6 +3184,11 @@ GSList *imap_get_num_list(Folder *folder, FolderItem *_item)
                }
        }
 
+       dir = folder_item_get_path((FolderItem *)item);
+       debug_print("removing old messages from %s\n", dir);
+       remove_numbered_files_not_in_list(dir, msgnum_list);
+       g_free(dir);
+
        return msgnum_list;
 }
 
index 9876a67ee75a6c159ea8acc17136fb5f049147de..d35e61c490eeb4549b935a0de2f7372bd7f9c9c8 100644 (file)
@@ -1049,6 +1049,7 @@ GSList *news_get_num_list(Folder *folder, FolderItem *item)
        NNTPSession *session;
        gint i, ok, num, first, last;
        GSList *msgnum_list = NULL;
+       gchar *dir;
 
        session = news_session_get(folder);
        g_return_val_if_fail(session != NULL, NULL);
@@ -1072,6 +1073,11 @@ GSList *news_get_num_list(Folder *folder, FolderItem *item)
                msgnum_list = g_slist_prepend(msgnum_list, GINT_TO_POINTER(i));
        }
 
+       dir = folder_item_get_path(item);
+       debug_print("removing old messages from %d to %d in %s\n", first, last, dir);
+       remove_numbered_files(dir, 1, first - 1);
+       g_free(dir);
+
        return msgnum_list;
 }
 
index bd6331d84022aae977873cf792477a59b969426d..ff10b1d117724fe0748de3b73a80145756f2a182 100644 (file)
@@ -1827,6 +1827,51 @@ gint remove_numbered_files(const gchar *dir, guint first, guint last)
        return 0;
 }
 
+gint remove_numbered_files_not_in_list(const gchar *dir, GSList *numberlist)
+{
+       DIR *dp;
+       struct dirent *d;
+       gchar *prev_dir;
+       gint fileno;
+
+       prev_dir = g_get_current_dir();
+
+       if (chdir(dir) < 0) {
+               FILE_OP_ERROR(dir, "chdir");
+               g_free(prev_dir);
+               return -1;
+       }
+
+       if ((dp = opendir(".")) == NULL) {
+               FILE_OP_ERROR(dir, "opendir");
+               g_free(prev_dir);
+               return -1;
+       }
+
+       while ((d = readdir(dp)) != NULL) {
+               fileno = to_number(d->d_name);
+               if (fileno >= 0 && (g_slist_find(numberlist, GINT_TO_POINTER(fileno)) == NULL)) {
+                       debug_print("removing unwanted file %d from %s\n", fileno, dir);
+                       if (is_dir_exist(d->d_name))
+                               continue;
+                       if (unlink(d->d_name) < 0)
+                               FILE_OP_ERROR(d->d_name, "unlink");
+               }
+       }
+
+       closedir(dp);
+
+       if (chdir(prev_dir) < 0) {
+               FILE_OP_ERROR(prev_dir, "chdir");
+               g_free(prev_dir);
+               return -1;
+       }
+
+       g_free(prev_dir);
+
+       return 0;
+}
+
 gint remove_all_numbered_files(const gchar *dir)
 {
        return remove_numbered_files(dir, 0, UINT_MAX);
index 85cd4ce6b920e3a99ceb3be591a8ab2ae8d01168..0383a780aaeab616b42bfeceb84627d1055f5ced 100644 (file)
@@ -332,6 +332,8 @@ gint remove_all_files               (const gchar    *dir);
 gint remove_numbered_files     (const gchar    *dir,
                                 guint           first,
                                 guint           last);
+gint remove_numbered_files_not_in_list(const gchar *dir,
+                                      GSList *numberlist);
 gint remove_all_numbered_files (const gchar    *dir);
 gint remove_expired_files      (const gchar    *dir,
                                 guint           hours);