Return NULL when GisHttp fetch fails
authorAndy Spencer <andy753421@gmail.com>
Tue, 9 Feb 2010 18:59:53 +0000 (18:59 +0000)
committerAndy Spencer <andy753421@gmail.com>
Tue, 9 Feb 2010 18:59:53 +0000 (18:59 +0000)
src/data/gis-http.c

index d9f29a5d52c1f87ce06c69b69ca218b6780bc9c9..0765415f3e974d87c42d4879d63a663274cd7974 100644 (file)
@@ -154,20 +154,22 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                soup_message_headers_set_range(message->request_headers, ftell(fp), -1);
                soup_session_send_message(http->soup, message);
 
+               /* Close file */
+               fclose(fp);
+               if (path != part && SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) {
+                       g_rename(part, path);
+                       g_free(part);
+               }
+
                /* Finished */
                if (message->status_code == 416) {
                        /* Range unsatisfiable, file already complete */
-               } else if (!SOUP_STATUS_IS_SUCCESSFUL(message->status_code))
+               } else if (!SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) {
                        g_warning("GisHttp: done_cb - error copying file, status=%d\n"
                                        "\tsrc=%s\n"
                                        "\tdst=%s",
                                        message->status_code, uri, path);
-
-               /* Close file */
-               fclose(fp);
-               if (path != part && SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) {
-                       g_rename(part, path);
-                       g_free(part);
+                       return NULL;
                }
        }