mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2287] [CLOSED] [Other] use published size when download length probes fail #3963
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3963
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2287
Author: @KeyanHu-git
Created: 10/13/2026
Status: ❌ Closed
Base:
main← Head:fix/1915-download-length📝 Commits (4)
958882csetup: resume downloads when HEAD omits Content-Length5b049a6merge current main and complete serial downloads from response metadata4acfcbfUse published size in the existing download completion path7527e00Test published-size recovery and download verification boundaries📊 Changes
2 files changed (+112 additions, -1 deletions)
View changed files
📝
setup.py(+3 -1)➕
tools/test_setup_download_length.py(+109 -0)📄 Description
Problem and result
When HEAD and the one-byte range probe both fail to provide a length,
download()treats an early EOF as completion even if Strata already has the file's published size. A short file is renamed out of.part, and verification either stops with a size error or, without a published hash, marks the fragment as finished.Use the published size for transfer completion as well as verification. The existing downloader then resumes an interrupted transfer, keeps partial bytes when retries run out, and publishes the file only after receiving the expected length.
Related discussion
#1915. Version 0.2 added a range probe, which covers missing HEAD length when that probe succeeds. This fix covers the remaining case where both probes lack a size. The original ModelScope URL supplied Content-Length when checked on October 22; the regression below reproduces the remaining condition with a local HTTP server.
Approach
After the transport probes, fall back to the repository pin's size, or ModelScope's published size when there is no pin. Reuse the existing metadata lookup for hash verification.
The production diff moves the metadata lookup and adds a two-line fallback. Serial retries, parallel transfers, source identity and checksum verification retain their existing implementations.
Validation
Base:
011c9e60(0.2.2 / engine 0.1.47). Final revision:7527e00f. Python 3.12 on macOS and Windows.Passed: all 8 focused tests on both systems. They cover early EOF with a pin, metadata with and without a hash, exhausted retries preserving
.part, parallel transfer after a failed initial probe, an already complete.part, a transport/pin size conflict and a wrong hash. Six of these fail on the unmodified base; the size-conflict and hash checks pass on both.The early-EOF fixture supplies 262,144 of 2,633,785 bytes before closing. The patched serial transfer resumes at byte 262,144 and produces the exact original bytes. Exhausting retries preserves those 262,144 bytes without a final file or
.donemark.Failed: the combined suite passes 36/37 on both macOS and Windows. The shared redirect test counts the first piece twice (
[0, 0, 1, …, 40]instead of[0, 1, …, 40]). It uses a successful HEAD length, so this fallback is not entered. The production code for that path is unchanged. The same 37 tests on unmodified main report 4 failures and 3 errors on both systems, including the six focused regressions above.Not run: another multi-gigabyte transfer through the original reporter's network. All transfer tests above use real HTTP requests to a local server; published metadata is supplied by the fixture.
Limits
If neither transport probes nor published metadata provide a size, the existing unknown-length behavior remains. The fallback does not replace hash verification or change which model files Strata accepts.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.