+2002-07-26
+
+ * src/news.c: implement automatic cache expiration.
+ news_delete_expired_caches(): new.
+ news_get_article_list(): fixed a bug that nonexistent messages
+ were not removed from list.
+ * src/procmsg.[ch]: procmsg_get_last_num_in_msg_list(): renamed
+ procmsg_get_last_num_in_cache().
+ * src/utils.[ch]: remove_expired_files(): new.
+
2002-07-26
* src/inc.c:
+2002-07-27 [paul] 0.8.0claws22
+
+ * sync with 0.8.1cvs2
+ see ChangeLog 2002-07-26
+
2002-07-27 [christoph] 0.8.0claws21
* src/imap.c
+2002-07-26
+
+ * src/news.c: ¼«Æ°¥¥ã¥Ã¥·¥åºï½ü¤ò¼ÂÁõ¡£
+ news_delete_expired_caches(): ¿·µ¬¡£
+ news_get_article_list(): ¸ºß¤·¤Ê¤¤¥á¥Ã¥»¡¼¥¸¤¬¥ê¥¹¥È¤«¤éºï½ü
+ ¤µ¤ì¤Ê¤¤¥Ð¥°¤ò½¤Àµ¡£
+ * src/procmsg.[ch]: procmsg_get_last_num_in_msg_list():
+ procmsg_get_last_num_in_cache() ¤ò̾¾ÎÊѹ¹¡£
+ * src/utils.[ch]: remove_expired_files(): ¿·µ¬¡£
+
2002-07-26
* src/inc.c
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=claws21
+EXTRA_VERSION=claws22
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl set $target
if (!session) {
mlist = procmsg_read_cache(item, FALSE);
- item->last_num = procmsg_get_last_num_in_cache(mlist);
+ item->last_num = procmsg_get_last_num_in_msg_list(mlist);
procmsg_set_flags(mlist, item);
statusbar_pop_all();
return mlist;
mlist = procmsg_read_cache(item, FALSE);
procmsg_set_flags(mlist, item);
- cache_last = procmsg_get_last_num_in_cache(mlist);
+ cache_last = procmsg_get_last_num_in_msg_list(mlist);
/* calculating the range of envelope to get */
if (item->mtime != uid_validity) {
FolderItem *item,
gint first);
static void news_delete_all_articles (FolderItem *item);
+static void news_delete_expired_caches (GSList *alist,
+ FolderItem *item);
static gint news_remove_msg (Folder *folder,
FolderItem *item,
if (!session) {
alist = procmsg_read_cache(item, FALSE);
- item->last_num = procmsg_get_last_num_in_cache(alist);
+ item->last_num = procmsg_get_last_num_in_msg_list(alist);
} else if (use_cache) {
GSList *newlist;
gint cache_last;
alist = procmsg_read_cache(item, FALSE);
- cache_last = procmsg_get_last_num_in_cache(alist);
+ cache_last = procmsg_get_last_num_in_msg_list(alist);
newlist = news_get_uncached_articles
(session, item, cache_last, &first, &last);
- alist = news_delete_old_articles(alist, item, first);
+ if (first == 0 && last == 0) {
+ news_delete_all_articles(item);
+ procmsg_msg_list_free(alist);
+ alist = NULL;
+ } else {
+ alist = news_delete_old_articles(alist, item, first);
+ news_delete_expired_caches(alist, item);
+ }
alist = g_slist_concat(alist, newlist);
+
item->last_num = last;
} else {
gint last;
GSList *llast = NULL;
MsgInfo *msginfo;
- if (rfirst) *rfirst = 0;
- if (rlast) *rlast = 0;
+ if (rfirst) *rfirst = -1;
+ if (rlast) *rlast = -1;
g_return_val_if_fail(session != NULL, NULL);
g_return_val_if_fail(item != NULL, NULL);
first, last);
return NULL;
}
+
+ if (rfirst) *rfirst = first;
+ if (rlast) *rlast = last;
+
if (cache_last < first)
begin = first;
else if (last < cache_last)
begin = cache_last + 1;
end = last;
- if (rfirst) *rfirst = first;
- if (rlast) *rlast = last;
-
if (prefs_common.max_articles > 0 &&
end - begin + 1 > prefs_common.max_articles)
begin = end - prefs_common.max_articles + 1;
if (first < 2) return alist;
- debug_print(_("Deleting cached articles 1 - %d ... "), first - 1);
+ debug_print("Deleting cached articles 1 - %d ...\n", first - 1);
dir = folder_item_get_path(item);
remove_numbered_files(dir, 1, first - 1);
cur = next;
}
- debug_print(_("done.\n"));
return alist;
}
g_return_if_fail(item->folder != NULL);
g_return_if_fail(item->folder->type == F_NEWS);
- debug_print(_("\tDeleting all cached articles... "));
+ debug_print("Deleting all cached articles...\n");
dir = folder_item_get_path(item);
remove_all_numbered_files(dir);
g_free(dir);
+}
- debug_print(_("done.\n"));
+static void news_delete_expired_caches(GSList *alist, FolderItem *item)
+{
+ gchar *dir;
+
+ g_return_if_fail(item != NULL);
+ g_return_if_fail(item->folder != NULL);
+ g_return_if_fail(item->folder->type == F_NEWS);
+
+ debug_print("Deleting expired cached articles...\n");
+
+ dir = folder_item_get_path(item);
+ remove_expired_files(dir, 24 * 7);
+ g_free(dir);
}
gint news_cancel_article(Folder * folder, MsgInfo * msginfo)
g_hash_table_destroy(mark_table);
}
-gint procmsg_get_last_num_in_cache(GSList *mlist)
+gint procmsg_get_last_num_in_msg_list(GSList *mlist)
{
GSList *cur;
MsgInfo *msginfo;
gint last = 0;
- if (mlist == NULL) return 0;
-
for (cur = mlist; cur != NULL; cur = cur->next) {
msginfo = (MsgInfo *)cur->data;
if (msginfo && msginfo->msgnum > last)
gboolean scan_file);
void procmsg_set_flags (GSList *mlist,
FolderItem *item);
-gint procmsg_get_last_num_in_cache (GSList *mlist);
+gint procmsg_get_last_num_in_msg_list(GSList *mlist);
void procmsg_msg_list_free (GSList *mlist);
void procmsg_write_cache (MsgInfo *msginfo,
FILE *fp);
return remove_numbered_files(dir, 0, UINT_MAX);
}
+gint remove_expired_files(const gchar *dir, guint hours)
+{
+ DIR *dp;
+ struct dirent *d;
+ struct stat s;
+ gchar *prev_dir;
+ gint fileno;
+ time_t mtime, now, expire_time;
+
+ prev_dir = g_get_current_dir();
+
+ if (chdir(dir) < 0) {
+ FILE_OP_ERROR(dir, "chdir");
+ return -1;
+ }
+
+ if ((dp = opendir(".")) == NULL) {
+ FILE_OP_ERROR(dir, "opendir");
+ return -1;
+ }
+
+ now = time(NULL);
+ expire_time = hours * 60 * 60;
+
+ while ((d = readdir(dp)) != NULL) {
+ fileno = to_number(d->d_name);
+ if (fileno >= 0) {
+ if (stat(d->d_name, &s) < 0) {
+ FILE_OP_ERROR(d->d_name, "stat");
+ continue;
+ }
+ if (S_ISDIR(s.st_mode))
+ continue;
+ mtime = MAX(s.st_mtime, s.st_atime);
+ if (now - mtime > expire_time) {
+ 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_dir_recursive(const gchar *dir)
{
struct stat s;
guint first,
guint last);
gint remove_all_numbered_files (const gchar *dir);
+gint remove_expired_files (const gchar *dir,
+ guint hours);
gint remove_dir_recursive (const gchar *dir);
gint copy_file (const gchar *src,
const gchar *dest);