const gchar *name,
const gchar *path);
+static gchar *mh_get_new_msg_filename (FolderItem *dest);
+
static GSList *mh_get_uncached_msgs (GHashTable *msg_table,
FolderItem *item);
static MsgInfo *mh_parse_msg (const gchar *file,
return file;
}
-gchar *mh_get_newmsg_filename(FolderItem *dest)
+static gchar *mh_get_new_msg_filename(FolderItem *dest)
{
gchar *destfile;
gchar *destpath;
- gboolean found = FALSE;
destpath = folder_item_get_path(dest);
g_return_val_if_fail(destpath != NULL, NULL);
+
if (!is_dir_exist(destpath))
make_dir_hier(destpath);
- do {
+ for (;;) {
destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR,
dest->last_num + 1);
- if(is_file_exist(destfile)) {
+ if (is_file_entry_exist(destfile)) {
dest->last_num++;
g_free(destfile);
- } else {
- found = TRUE;
- }
- } while(!found);
+ } else
+ break;
+ }
+
g_free(destpath);
return destfile;
if (dest->last_num < 0) return -1;
}
- destfile = mh_get_newmsg_filename(dest);
- if(!destfile) return -1;
+ destfile = mh_get_new_msg_filename(dest);
+ g_return_val_if_fail(destfile != NULL, -1);
if (link(file, destfile) < 0) {
if (copy_file(file, destfile) < 0) {
prefs = dest->prefs;
- destdir = folder_item_get_path(dest);
+ destfile = mh_get_new_msg_filename(dest);
+ g_return_val_if_fail(destfile != NULL, -1);
debug_print(_("Moving message %s%c%d to %s ...\n"),
msginfo->folder->path, G_DIR_SEPARATOR,
msginfo->msgnum, dest->path);
srcfile = procmsg_get_message_file(msginfo);
- destfile = mh_get_newmsg_filename(dest);
+ destfile = mh_get_new_msg_filename(dest);
if(!destfile) return -1;
+ srcfile = procmsg_get_message_file(msginfo);
if (move_file(srcfile, destfile) < 0) {
g_free(srcfile);
g_free(destfile);
- g_free(destdir);
return -1;
}
g_free(destfile);
dest->last_num++;
+ destdir = folder_item_get_path(dest);
if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
g_warning(_("Can't open mark file.\n"));
else {
msginfo->folder->path, G_DIR_SEPARATOR,
msginfo->msgnum, dest->path);
+ destfile = mh_get_new_msg_filename(dest);
+ if (!destfile) break;
srcfile = procmsg_get_message_file(msginfo);
- destfile = mh_get_newmsg_filename(dest);
+ destfile = mh_get_new_msg_filename(dest);
if(!destfile) return -1;
if (move_file(srcfile, destfile) < 0) {
prefs = dest->prefs;
- destdir = folder_item_get_path(dest);
- if (!is_dir_exist(destdir))
- make_dir_hier(destdir);
-
- if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
- g_warning(_("Can't open mark file.\n"));
+ destfile = mh_get_new_msg_filename(dest);
+ g_return_val_if_fail(destfile != NULL, -1);
debug_print(_("Copying message %s%c%d to %s ...\n"),
msginfo->folder->path, G_DIR_SEPARATOR,
msginfo->msgnum, dest->path);
+
srcfile = procmsg_get_message_file(msginfo);
- destfile = mh_get_newmsg_filename(dest);
- if(!destfile) {
- g_free(srcfile);
- if (fp) fclose(fp);
- return -1;
- }
-
- dest->op_count--;
if (copy_file(srcfile, destfile) < 0) {
FILE_OP_ERROR(srcfile, "copy");
g_free(srcfile);
g_free(destfile);
- g_free(destdir);
return -1;
}
g_free(destfile);
dest->last_num++;
+ destdir = folder_item_get_path(dest);
if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
g_warning(_("Can't open mark file.\n"));
else {
msginfo->folder->path, G_DIR_SEPARATOR,
msginfo->msgnum, dest->path);
+ destfile = mh_get_new_msg_filename(dest);
+ if (!destfile) break;
srcfile = procmsg_get_message_file(msginfo);
- destfile = mh_get_newmsg_filename(dest);
- if(!destfile) {
- g_free(srcfile);
- break;
- }
if (copy_file(srcfile, destfile) < 0) {
FILE_OP_ERROR(srcfile, "copy");
return FALSE;
}
-void mh_scan_folder(Folder *folder, FolderItem *item)
+gint mh_scan_folder(Folder *folder, FolderItem *item)
{
gchar *path;
DIR *dp;
gint num;
gint n_msg = 0;
- g_return_if_fail(item != NULL);
+ g_return_val_if_fail(item != NULL, -1);
debug_print("mh_scan_folder(): Scanning %s ...\n", item->path);
path = folder_item_get_path(item);
- g_return_if_fail(path != NULL);
+ g_return_val_if_fail(path != NULL, -1);
if (change_dir(path) < 0) {
g_free(path);
- return;
+ return -1;
}
g_free(path);
if ((dp = opendir(".")) == NULL) {
FILE_OP_ERROR(item->path, "opendir");
- return;
+ return -1;
}
if (folder->ui_func)
if (n_msg == 0)
item->new = item->unread = item->total = 0;
else {
- gint new, unread, total;
+ gint new, unread, total, min, max;
- procmsg_get_mark_sum(".", &new, &unread, &total);
+ procmsg_get_mark_sum(".", &new, &unread, &total, &min, &max, 0);
if (n_msg > total) {
new += n_msg - total;
unread += n_msg - total;
debug_print(_("Last number in dir %s = %d\n"), item->path, max);
item->last_num = max;
+
+ return 0;
}
void mh_scan_tree(Folder *folder)
pptable = folder_persist_prefs_new(folder);
+ prefs_scoring_clear();
+ prefs_filtering_clear();
folder_tree_destroy(folder);
item = folder_item_new(folder->name, NULL);
item->folder = folder;
}
g_free(rootpath);
+ mh_create_tree(folder);
mh_scan_tree_recursive(item, pptable);
folder_persist_prefs_free(pptable);
+
+ prefs_matcher_read_config();
}
#define MAKE_DIR_IF_NOT_EXIST(dir) \
new_item = folder_item_new(d->d_name, entry);
folder_item_append(item, new_item);
if (!item->path) {
- if (!strcmp(d->d_name, "inbox")) {
+ if (!strcmp(d->d_name, INBOX_DIR)) {
new_item->stype = F_INBOX;
item->folder->inbox = new_item;
- } else if (!strcmp(d->d_name, "outbox")) {
+ } else if (!strcmp(d->d_name, OUTBOX_DIR)) {
new_item->stype = F_OUTBOX;
item->folder->outbox = new_item;
- } else if (!strcmp(d->d_name, "draft")) {
+ } else if (!strcmp(d->d_name, DRAFT_DIR)) {
new_item->stype = F_DRAFT;
item->folder->draft = new_item;
- } else if (!strcmp(d->d_name, "queue")) {
+ } else if (!strcmp(d->d_name, QUEUE_DIR)) {
new_item->stype = F_QUEUE;
item->folder->queue = new_item;
- } else if (!strcmp(d->d_name, "trash")) {
+ } else if (!strcmp(d->d_name, TRASH_DIR)) {
new_item->stype = F_TRASH;
item->folder->trash = new_item;
}
closedir(dp);
if (item->path) {
- gint new, unread, total;
+ gint new, unread, total, min, max;
- procmsg_get_mark_sum(item->path, &new, &unread, &total);
+ procmsg_get_mark_sum(item->path, &new, &unread, &total,
+ &min, &max, 0);
if (n_msg > total) {
new += n_msg - total;
unread += n_msg - total;