fix: support resume download for /pull #1957
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe Your Changes
This pull request introduces several improvements and new features to the download service in the engine. The most important changes include adding support for resuming downloads, enhancing logging for download progress, and refactoring the
GetDownloadTask
function.Enhancements to download functionality:
engine/services/download_service.cc
: Added logic to check for existing files and resume downloads if the file is partially downloaded. This includes updating the file open mode to "ab" for appending and setting theCURLOPT_RESUME_FROM_LARGE
option inSetUpCurlHandle
to resume downloads. [1] [2] [3] [4]Logging improvements:
engine/services/download_service.cc
: Enhanced logging to provide more detailed information about the download process, including the size of existing files and the number of bytes needed to complete the download.Refactoring and code cleanup:
engine/services/model_service.cc
: Moved theGetDownloadTask
function to a more appropriate location within theModelService
class and refactored it to include file size information for each download item. [1] [2]engine/services/download_service.h
: Updated theSetUpCurlHandle
function signature to include aresume_download
parameter.engine/services/model_service.h
: Added theGetDownloadTask
function declaration to theModelService
class.Minor fixes:
engine/cli/utils/download_progress.cc
: Fixed an off-by-one error in string truncation logic.engine/services/download_service.cc
: Added handling for HTTP 206 (Partial Content) response code inProcessCompletedTransfers
.Fixes Issues
Self Checklist