From ec49abcb7ce88f0549fa54a66d4523e5a355b942 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 11 Feb 2009 09:54:05 +0000 Subject: ** Fix for bug #333716 2009-02-11 Milan Crha ** Fix for bug #333716 * em-format-html.c: (emfh_gethttp): Do not store incomplete or broken files in a cache. svn path=/trunk/; revision=37244 --- mail/em-format-html.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'mail/em-format-html.c') diff --git a/mail/em-format-html.c b/mail/em-format-html.c index f813ef01fb..21cbcf0e92 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -533,17 +533,12 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, int cancelled) camel_operation_progress(NULL, pc_complete); } d(printf(" read %d bytes\n", n)); - if (costream && camel_stream_write(costream, buffer, n) == -1) { - camel_data_cache_remove(emfh_http_cache, EMFH_HTTP_CACHE_PATH, job->u.uri, NULL); - camel_object_unref(costream); - costream = NULL; + if (costream && camel_stream_write (costream, buffer, n) == -1) { + n = -1; + break; } camel_stream_write(job->stream, buffer, n); - } else if (n < 0 && costream) { - camel_data_cache_remove(emfh_http_cache, EMFH_HTTP_CACHE_PATH, job->u.uri, NULL); - camel_object_unref(costream); - costream = NULL; } } while (n>0); @@ -551,8 +546,12 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, int cancelled) if (n == 0) camel_stream_close(job->stream); - if (costream) + if (costream) { + /* do not store broken files in a cache */ + if (n != 0) + camel_data_cache_remove(emfh_http_cache, EMFH_HTTP_CACHE_PATH, job->u.uri, NULL); camel_object_unref(costream); + } camel_object_unref(instream); done: -- cgit v1.2.3