feat: Add resumable download support for nexa pull #847
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.
🎯 Feature
Implements #803
Adds resumable download support for
nexa pull, allowing interrupted model downloads to automatically resume from where they stopped.💡 Motivation
Problem: Large model downloads (10GB+) often fail due to network interruptions, forcing users to restart from scratch and waste bandwidth.
Solution: Automatic progress tracking that saves download state every 5 seconds, enabling seamless resume on next
nexa pull.✨ Features
Core Functionality
Technical Implementation
📝 Changes
New Files
runner/internal/types/download.go(+210 lines)DownloadProgress: Main progress trackerFileProgress: Per-file download stateCompletedRange: Byte range trackingrunner/internal/types/download_test.go(+270 lines)Modified Files
runner/internal/model_hub/model_hub.go(+83 lines, -15 lines)StartDownloadto check for existing progress🧪 Testing
Unit Tests (All Passing ✅)
go test ./runner/internal/types -run TestDownload -vTest Coverage:
Manual Testing Scenarios
Test 1: Interrupt and Resume
Start download
nexa pull NexaAI/Qwen3-VL-4B-Instruct-GGUF:Q4_0
Interrupt with Ctrl+C after 50% downloaded
Resume (should skip completed ranges)
nexa pull NexaAI/Qwen3-VL-4B-Instruct-GGUF:Q4_0Expected: Download continues from 50%, shows "Resuming download" message
Test 2: Complete Download Cleanup
Complete a full download
nexa pull
Verify progress file is removed
ls ~/.cache/nexa.ai/nexa_sdk/models//.download_progress.jsonExpected: Progress file deleted on success
📊 Performance Impact
Benchmarks
Network Efficiency
🔍 Technical Details
Progress File Format
{
"model_name": "NexaAI/Qwen3-VL-4B",
"total_size": 10000000000,
"downloaded": 5000000000,
"files": {
"model.gguf": {
"file_name": "model.gguf",
"total_size": 10000000000,
"downloaded": 5000000000,
"completed_ranges": [
{"start": 0, "end": 5000000000}
]
}
},
"last_modified": "2025-11-11T10:30:00Z",
"version": 1
}### Range Merging Algorithm
Automatically merges adjacent/overlapping byte ranges: