aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/local
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers/local')
-rw-r--r--camel/providers/local/camel-local-store.c14
-rw-r--r--camel/providers/local/camel-maildir-store.c9
-rw-r--r--camel/providers/local/camel-mh-store.c5
-rw-r--r--camel/providers/local/camel-spool-store.c29
4 files changed, 28 insertions, 29 deletions
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index b325df769a..a794b778f3 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -319,7 +319,7 @@ static void
rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex)
{
char *path = CAMEL_LOCAL_STORE (store)->toplevel_dir;
- CamelLocalFolder *folder;
+ CamelLocalFolder *folder = NULL;
char *newibex = g_strdup_printf("%s%s.ibex", path, new);
char *oldibex = g_strdup_printf("%s%s.ibex", path, old);
@@ -327,8 +327,7 @@ rename_folder(CamelStore *store, const char *old, const char *new, CamelExceptio
d(printf("local rename folder '%s' '%s'\n", old, new));
- CAMEL_STORE_LOCK(store, cache_lock);
- folder = g_hash_table_lookup(store->folders, old);
+ folder = camel_object_bag_get(store->folders, old);
if (folder && folder->index) {
if (camel_index_rename(folder->index, newibex) == -1)
goto ibex_failed;
@@ -344,11 +343,12 @@ rename_folder(CamelStore *store, const char *old, const char *new, CamelExceptio
if (xrename(old, new, path, "", FALSE, ex))
goto base_failed;
- CAMEL_STORE_UNLOCK(store, cache_lock);
-
g_free(newibex);
g_free(oldibex);
+ if (folder)
+ camel_object_unref(folder);
+
return;
base_failed:
@@ -365,9 +365,11 @@ ibex_failed:
_("Could not rename '%s': %s"),
old, g_strerror (errno));
- CAMEL_STORE_UNLOCK(store, cache_lock);
g_free(newibex);
g_free(oldibex);
+
+ if (folder)
+ camel_object_unref(folder);
}
/* default implementation, only delete metadata */
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 8e6cc1ee9d..c84c37158c 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -273,16 +273,15 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
base = path;
/* if we have this folder open, get the real unread count */
- unread = -1;
-
- CAMEL_STORE_LOCK(store, cache_lock);
- folder = g_hash_table_lookup(store->folders, path);
+ folder = camel_object_bag_get(store->folders, path);
if (folder) {
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
camel_folder_refresh_info(folder, NULL);
unread = camel_folder_get_unread_message_count(folder);
+ camel_object_unref(folder);
+ } else {
+ unread = -1;
}
- CAMEL_STORE_UNLOCK(store, cache_lock);
/* if we dont have a folder, then scan the directory and get the unread
count from there, which is reasonably cheap (on decent filesystem) */
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index 6c442d335b..7fe68ef4b5 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -300,14 +300,13 @@ static CamelFolderInfo *folder_info_new(CamelStore *store, const char *root, con
fi->unread_message_count = 0;
/* check unread count if open */
- CAMEL_STORE_LOCK(store, cache_lock);
- folder = g_hash_table_lookup(store->folders, path);
+ folder = camel_object_bag_get(store->folders, path);
if (folder) {
if ((((CamelMhStore *)store)->flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
camel_folder_refresh_info(folder, NULL);
fi->unread_message_count = camel_folder_get_unread_message_count(folder);
+ camel_object_unref(folder);
}
- CAMEL_STORE_UNLOCK(store, cache_lock);
/* We could: if we have no folder, and FAST isn't specified, perform a full
scan of all messages for their status flags. But its probably not worth
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index f2cbdd1e55..9419d897a8 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -285,13 +285,13 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
} else if (S_ISREG(st.st_mode)) {
/* incase we start scanning from a file. messy duplication :-/ */
if (path) {
- CAMEL_STORE_LOCK(store, cache_lock);
- folder = g_hash_table_lookup(store->folders, path);
- if (folder)
+ folder = camel_object_bag_get(store->folders, path);
+ if (folder) {
+ /* should this refresh if ! FAST? */
unread = camel_folder_get_unread_message_count(folder);
- else
+ camel_object_unref(folder);
+ } else
unread = -1;
- CAMEL_STORE_UNLOCK(store, cache_lock);
tmp = strrchr(path, '/');
if (tmp)
tmp++;
@@ -346,13 +346,13 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
if (S_ISREG(st.st_mode)) {
/* first, see if we already have it open */
- CAMEL_STORE_LOCK(store, cache_lock);
- folder = g_hash_table_lookup(store->folders, fname);
- if (folder)
+ folder = camel_object_bag_get(store->folders, path);
+ if (folder) {
+ /* should this refresh if ! FAST? */
unread = camel_folder_get_unread_message_count(folder);
- else
+ camel_object_unref(folder);
+ } else
unread = -1;
- CAMEL_STORE_UNLOCK(store, cache_lock);
/* no? check its content to see if its a folder or not */
if (folder == NULL) {
@@ -457,13 +457,12 @@ get_folder_info_mbox(CamelStore *store, const char *top, guint32 flags, CamelExc
fi->name = g_strdup("INBOX");
fi->url = g_strdup_printf("%s:%s#%s", service->url->protocol, service->url->path, fi->name);
- CAMEL_STORE_LOCK(store, cache_lock);
- folder = g_hash_table_lookup(store->folders, fi->full_name);
- if (folder)
+ folder = camel_object_bag_get(store->folders, fi->full_name);
+ if (folder) {
fi->unread_message_count = camel_folder_get_unread_message_count(folder);
- else
+ camel_object_unref(folder);
+ } else
fi->unread_message_count = -1;
- CAMEL_STORE_UNLOCK(store, cache_lock);
camel_folder_info_build_path(fi, '/');
}