Fix bug 4220 "generates files in cache without content"
authorRicardo Mones <ricardo@mones.org>
Sun, 21 Jun 2020 17:41:40 +0000 (19:41 +0200)
committerRicardo Mones <ricardo@mones.org>
Sun, 21 Jun 2020 17:41:40 +0000 (19:41 +0200)
Also replace "safe" call, since file should not be locked and is
going to be deleted anyway.

src/plugins/libravatar/libravatar_image.c

index b5675aac2dd2ea499c96214f2b80d3944de78123..6d0fdac76ddbf5ac3e56707cb7a32e61dc1aa109 100644 (file)
@@ -83,6 +83,7 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha
        curl = curl_easy_init();
        if (curl == NULL) {
                g_warning("could not initialize curl to get image from URL");
+               unlink(filename);
                claws_fclose(file);
                return NULL;
        }
@@ -113,7 +114,8 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
                debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res));
-               claws_safe_fclose(file);
+               unlink(filename);
+               claws_fclose(file);
        } else {
                filesize = ftell(file);
                claws_safe_fclose(file);