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
This commit is contained in:
abraunegg 2025-08-02 11:15:23 +10:00 committed by GitHub
commit 5f14530745
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -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

View file

@ -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;