diff options
Diffstat (limited to 'mail/em-format-html.c')
-rw-r--r-- | mail/em-format-html.c | 17 |
1 files changed, 8 insertions, 9 deletions
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: |