static gint xrename (CamelStore *store, const gchar *old_name, const gchar *new_name, const gchar *ext, gboolean missingok) { CamelLocalStore *ls = (CamelLocalStore *) store; gchar *oldpath, *newpath; struct stat st; gint ret = -1; if (ext != NULL) { oldpath = camel_local_store_get_meta_path (ls, old_name, ext); newpath = camel_local_store_get_meta_path (ls, new_name, ext); } else { oldpath = camel_local_store_get_full_path (ls, old_name); newpath = camel_local_store_get_full_path (ls, new_name); } if (g_stat (oldpath, &st) == -1) { if (missingok && errno == ENOENT) { ret = 0; } else { ret = -1; } #ifndef G_OS_WIN32 } else if (S_ISDIR (st.st_mode)) { /* use rename for dirs */ if (g_rename (oldpath, newpath) == 0 || g_stat (newpath, &st) == 0) { ret = 0; } else { ret = -1; } } else if (link (oldpath, newpath) == 0 /* and link for files */ ||(g_stat (newpath, &st) == 0 && st.st_nlink == 2)) { if (unlink (oldpath) == 0) { ret = 0; } else { unlink (newpath); ret = -1; } } else { ret = -1; #else } else if ((!g_file_test (newpath, G_FILE_TEST_EXISTS) || g_remove (newpath) == 0) &&
/* NB: duplicated in maildir store */ static void fill_fi (CamelStore *store, CamelFolderInfo *fi, guint32 flags) { CamelFolder *folder; fi->unread = -1; fi->total = -1; folder = camel_object_bag_peek (store->folders, fi->full_name); if (folder) { if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) camel_folder_refresh_info_sync (folder, NULL, NULL); fi->unread = camel_folder_get_unread_message_count (folder); fi->total = camel_folder_get_message_count (folder); g_object_unref (folder); } else { gchar *path, *folderpath; CamelMboxSummary *mbs; /* This should be fast enough not to have to test for INFO_FAST */ path = camel_local_store_get_meta_path(store, fi->full_name, ".ev-summary"); folderpath = camel_local_store_get_full_path (store, fi->full_name); mbs = (CamelMboxSummary *)camel_mbox_summary_new (NULL, path, folderpath, NULL); /* FIXME[disk-summary] track exception */ if (camel_folder_summary_header_load_from_db ((CamelFolderSummary *)mbs, store, fi->full_name, NULL) != -1) { fi->unread = ((CamelFolderSummary *)mbs)->unread_count; fi->total = ((CamelFolderSummary *)mbs)->saved_count; } g_object_unref (mbs); g_free (folderpath); g_free (path); } if (camel_local_store_is_main_store (CAMEL_LOCAL_STORE (store)) && fi->full_name && (fi->flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_NORMAL) fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) | camel_local_store_get_folder_type_by_full_name (CAMEL_LOCAL_STORE (store), fi->full_name); }