From 4a52b7b9a9c00a9cb5fecca624c8f5590081e316 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 9 Sep 2002 20:28:35 +0000 Subject: Fixes bug #4224 2002-09-09 Jeffrey Stedfast Fixes bug #4224 * providers/imap/camel-imap-folder.c (camel_imap_folder_fetch_data): Pass ex into camel_imap_message_cache_get(). * providers/imap/camel-imap-message-cache.c (camel_imap_message_cache_get): Now takes an exception and sets it on fail. (camel_imap_message_cache_copy): Updated to properly handle cache_get error conditions. svn path=/trunk/; revision=18027 --- camel/providers/imap/camel-imap-folder.c | 9 ++++++--- camel/providers/imap/camel-imap-message-cache.c | 27 ++++++++++++++++--------- camel/providers/imap/camel-imap-message-cache.h | 4 +++- camel/providers/imap/camel-imap-store.c | 2 +- 4 files changed, 28 insertions(+), 14 deletions(-) (limited to 'camel/providers/imap') diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 1a2f5a79e9..0f77d80d75 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -2410,9 +2410,12 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, CAMEL_SERVICE_LOCK (store, connect_lock); CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); - stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text); - if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0"))) - stream = camel_imap_message_cache_get (imap_folder->cache, uid, ""); + stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text, ex); + if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0"))) { + camel_exception_clear (ex); + stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", ex); + } + if (stream || cache_only) { CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); CAMEL_SERVICE_UNLOCK (store, connect_lock); diff --git a/camel/providers/imap/camel-imap-message-cache.c b/camel/providers/imap/camel-imap-message-cache.c index 0701ca45e4..559c6d2f88 100644 --- a/camel/providers/imap/camel-imap-message-cache.c +++ b/camel/providers/imap/camel-imap-message-cache.c @@ -384,20 +384,21 @@ camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache, * @cache: the cache * @uid: the UID of the data to get * @part_spec: the part_spec of the data to get + * @ex: exception * * Return value: a CamelStream containing the cached data (which the * caller must unref), or %NULL if that data is not cached. **/ CamelStream * camel_imap_message_cache_get (CamelImapMessageCache *cache, const char *uid, - const char *part_spec) + const char *part_spec, CamelException *ex) { CamelStream *stream; char *path, *key; - + if (uid[0] == 0) return NULL; - + path = g_strdup_printf ("%s/%s.%s", cache->path, uid, part_spec); key = strrchr (path, '/') + 1; stream = g_hash_table_lookup (cache->parts, key); @@ -409,8 +410,14 @@ camel_imap_message_cache_get (CamelImapMessageCache *cache, const char *uid, } stream = camel_stream_fs_new_with_name (path, O_RDONLY, 0); - if (stream) + if (stream) { cache_put (cache, uid, key, stream); + } else { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Failed to cache %s: %s"), + part_spec, g_strerror (errno)); + } + g_free (path); return stream; @@ -502,17 +509,19 @@ camel_imap_message_cache_copy (CamelImapMessageCache *source, CamelStream *stream; char *part; int i; - + subparts = g_hash_table_lookup (source->parts, source_uid); if (!subparts || !subparts->len) return; - + for (i = 0; i < subparts->len; i++) { part = strchr (subparts->pdata[i], '.'); if (!part++) continue; - stream = camel_imap_message_cache_get (source, source_uid, part); - camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream, ex); - camel_object_unref (CAMEL_OBJECT (stream)); + + if ((stream = camel_imap_message_cache_get (source, source_uid, part, ex))) { + camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream, ex); + camel_object_unref (CAMEL_OBJECT (stream)); + } } } diff --git a/camel/providers/imap/camel-imap-message-cache.h b/camel/providers/imap/camel-imap-message-cache.h index eb3f056b44..c79195cfa4 100644 --- a/camel/providers/imap/camel-imap-message-cache.h +++ b/camel/providers/imap/camel-imap-message-cache.h @@ -87,7 +87,9 @@ void camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache, CamelStream *camel_imap_message_cache_get (CamelImapMessageCache *cache, const char *uid, - const char *part_spec); + const char *part_spec, + CamelException *ex); + void camel_imap_message_cache_remove (CamelImapMessageCache *cache, const char *uid); diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index af4192e0c6..f095c664db 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -1223,7 +1223,7 @@ imap_connect_online (CamelService *service, CamelException *ex) if (!store->namespace) store->namespace = g_strdup (""); - + if (!store->dir_sep) { if (store->server_level >= IMAP_LEVEL_IMAP4REV1) { /* This idiom means "tell me the hierarchy separator -- cgit