]> git.ipfire.org Git - pakfire.git/commitdiff
xfer: Ensure we always cleanup on failure
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 31 Jan 2025 14:41:46 +0000 (14:41 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 31 Jan 2025 14:41:46 +0000 (14:41 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/xfer.c

index 44df48807c7d02af705f9db37bb386299bf4fa55..69c3901bdc6aab9fc2df2ab326d2396ac22e11a0 100644 (file)
@@ -1307,7 +1307,7 @@ pakfire_xfer_error_code_t pakfire_xfer_done(struct pakfire_xfer* xfer, int code)
        // Download Size
        r = curl_easy_getinfo(h, CURLINFO_SIZE_DOWNLOAD_T, &download_size);
        if (r)
-               return r;
+               goto ERROR;
 
        if (download_size)
                DEBUG(xfer->ctx, "  Download Size: %ld bytes\n", download_size);
@@ -1315,7 +1315,7 @@ pakfire_xfer_error_code_t pakfire_xfer_done(struct pakfire_xfer* xfer, int code)
        // Download Speed
        r = curl_easy_getinfo(h, CURLINFO_SPEED_DOWNLOAD_T, &download_speed);
        if (r)
-               return r;
+               goto ERROR;
 
        if (download_speed)
                DEBUG(xfer->ctx, "  Download Speed: %ld bps\n", download_speed);
@@ -1323,7 +1323,7 @@ pakfire_xfer_error_code_t pakfire_xfer_done(struct pakfire_xfer* xfer, int code)
        // Upload Size
        r = curl_easy_getinfo(h, CURLINFO_SIZE_UPLOAD_T, &upload_size);
        if (r)
-               return r;
+               goto ERROR;
 
        if (upload_size)
                DEBUG(xfer->ctx, "  Upload Size: %ld bytes\n", upload_size);
@@ -1331,7 +1331,7 @@ pakfire_xfer_error_code_t pakfire_xfer_done(struct pakfire_xfer* xfer, int code)
        // Upload Speed
        r = curl_easy_getinfo(h, CURLINFO_SPEED_UPLOAD_T, &upload_speed);
        if (r)
-               return r;
+               goto ERROR;
 
        if (upload_speed)
                DEBUG(xfer->ctx, "  Upload Speed: %ld bps\n", upload_speed);
@@ -1343,7 +1343,8 @@ pakfire_xfer_error_code_t pakfire_xfer_done(struct pakfire_xfer* xfer, int code)
                if (r != 1) {
                        ERROR(xfer->ctx, "Could not finish message digest computation: %s\n",
                                ERR_error_string(ERR_get_error(), NULL));
-                       return 1;
+                       r = -EBADMSG;
+                       goto ERROR;
                }
 
                // Message Digest