From 5f14530745dc021f767af57666468be8df77cf39 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 2 Aug 2025 11:15:23 +1000 Subject: [PATCH] Fix resumable downloads so that the curl engine offset point is reset post successful download (#3406) * Ensure that post successful download, the resumable offset point is reset to avoid `HTTP request returned status code 416 (Requested Range Not Satisfiable)` if the offset point is not reset and curl engine reused for another download --- src/curlEngine.d | 5 +++++ src/onedrive.d | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/curlEngine.d b/src/curlEngine.d index 59bc4997..9219ff8e 100644 --- a/src/curlEngine.d +++ b/src/curlEngine.d @@ -598,6 +598,11 @@ class CurlEngine { void setDownloadResumeOffset(long offset) { resumeFromOffset = offset; } + + // reset resumable offset point to negative value + void resetDownloadResumeOffset() { + resumeFromOffset = -1; + } } // Methods to control obtaining and releasing a CurlEngine instance from the curlEnginePool diff --git a/src/onedrive.d b/src/onedrive.d index 6f4cd3af..00d72219 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -1559,6 +1559,9 @@ class OneDriveApi { // Safe remove 'threadResumeDownloadFilePath' as if we get to this point, the file has been download successfully safeRemove(threadResumeDownloadFilePath); + + // Reset this curlEngine offset value now that the file has been downloaded successfully + curlEngine.resetDownloadResumeOffset(); // Return the applicable result return result;