Resume Transfers
Large file downloads can be interrupted by network drops, SSH disconnections, or app backgrounding on mobile. ZestSSH supports resumable downloads so you do not have to start over from the beginning when a transfer fails partway through.
How it works
Section titled “How it works”When you resume a download, ZestSSH performs the following steps:
- Check the local file. If a partial file already exists at the download path, ZestSSH reads its size to determine how many bytes were previously written.
- Stat the remote file. ZestSSH queries the SFTP server for the total size of the remote file.
- Compare. If the local file size is already equal to or greater than the remote file size, the download is already complete and no transfer occurs.
- Seek and append. If the local file is smaller than the remote file, ZestSSH opens the remote file, seeks to the byte offset matching the local file size, and begins reading from that point. The incoming data is appended to the existing local file rather than overwriting it.
- Report progress. Progress callbacks reflect the total transfer, not just the resumed portion. If a 100 MB file was 60 MB complete before interruption, the progress starts at 60% and counts up from there.
The resume operation is handled by the SFTPResumableTransfer class, which encapsulates the offset logic and progress reporting.
Progress reporting
Section titled “Progress reporting”During a resumable transfer, ZestSSH reports progress through the SFTPProgress object, which includes:
- bytesTransferred: Total bytes written so far (including the previously downloaded portion).
- totalBytes: The full size of the remote file.
- fractionComplete: A value between 0.0 and 1.0 representing overall completion.
- bytesPerSecond: Average transfer speed calculated from the elapsed time.
- estimatedRemaining: Estimated time to completion based on current speed. Returns null if the speed is zero or the transfer is already complete.
This means the UI progress bar and ETA display are accurate for the entire file, not just the remaining portion.
When resume applies
Section titled “When resume applies”Resumable transfers apply to downloads (remote to local). The feature activates automatically when:
- A file at the local download path already exists.
- That file is smaller than the corresponding remote file.
If the local file does not exist, the download starts from the beginning. If the local file is the same size as the remote file, the transfer is considered complete immediately.
Limitations
Section titled “Limitations”- File changes between attempts. Resume assumes the remote file has not changed since the partial download began. If the remote file was modified or truncated between the initial download and the resume, the resulting local file may be corrupted (the first portion is from the old version and the appended portion is from the new version). For critical files, consider deleting the partial local file and downloading fresh.
- Upload resume is not currently supported. Interrupted uploads must be restarted from the beginning.
- Checksum verification is not performed. ZestSSH does not compare checksums of the partial file against the remote. If you suspect data corruption, delete the local file and re-download.
Practical use
Section titled “Practical use”Resume is particularly valuable for:
- Large log files or database dumps transferred over flaky mobile connections.
- ISO images or firmware files where re-downloading gigabytes is costly in time and bandwidth.
- Any download on iOS where backgrounding the app may interrupt the SSH connection. When you return to ZestSSH and reconnect, you can resume the download from where it stopped.
Related
Section titled “Related”- SFTP Browser — the file browser interface.
- Parallel Transfers — download multiple files at once.