adaptivedemux2/downloadhelper: Don't mark transfer as complete/error if cancelled.
authorJan Schmidt <jan@centricular.com>
Thu, 13 Oct 2022 19:19:11 +0000 (06:19 +1100)
committerJan Schmidt <jan@centricular.com>
Fri, 4 Nov 2022 16:24:26 +0000 (03:24 +1100)
If the state of the download request was reset to UNSENT,
it was cancelled. Don't update the state to COMPLETE or ERRORED
in on_read_ready().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3314>

subprojects/gst-plugins-good/ext/adaptivedemux2/downloadhelper.c

index 21d7c1b..67e9bc6 100644 (file)
@@ -353,11 +353,13 @@ finish_transfer:
         G_GINT64_FORMAT, status_code, request->uri,
         request->range_start, request->range_end);
 
-    if (SOUP_STATUS_IS_SUCCESSFUL (status_code)
-        || SOUP_STATUS_IS_REDIRECTION (status_code))
-      request->state = DOWNLOAD_REQUEST_STATE_COMPLETE;
-    else
-      request->state = DOWNLOAD_REQUEST_STATE_ERROR;
+    if (request->state != DOWNLOAD_REQUEST_STATE_UNSENT) {
+      if (SOUP_STATUS_IS_SUCCESSFUL (status_code)
+          || SOUP_STATUS_IS_REDIRECTION (status_code))
+        request->state = DOWNLOAD_REQUEST_STATE_COMPLETE;
+      else
+        request->state = DOWNLOAD_REQUEST_STATE_ERROR;
+    }
   }
   request->download_end_time = now;