fix(submit): 分块上传的预算检查复用一分钟内读过的 blob 大小,存储读不到时回 503 让面板自动重试

This commit is contained in:
Lemon-miaow committed 2026-09-27 04:13:48 +08:00
1 parent 2f920cf1c9
commit d2730c6e5a
13 files changed
+335 -25

No files matched your search

+12 -5
View File
@@ -60,12 +60,16 @@ func TestContextUploadErrors(t *testing.T) {
code int
want string
msg string
// retry is the Retry-After the answer must carry, if any.
retry string
}{
{"offset mismatch", &submit.OffsetMismatchError{Received: 12}, 409, "upload_offset_mismatch", "the upload holds 12 bytes"},
{"busy", submit.ErrUploadBusy, 409, "upload_busy", ""},
{"part too large", fmt.Errorf("submit: write upload part: %w", submit.ErrPartTooLarge), 413, "part_too_large", ""},
{"not owned", submit.ErrNotFound, 404, "not_found", ""},
{"no part store", submit.ErrUploadsUnavailable, 503, "uploads_unavailable", ""},
{"offset mismatch", &submit.OffsetMismatchError{Received: 12}, 409, "upload_offset_mismatch", "the upload holds 12 bytes", ""},
{"busy", submit.ErrUploadBusy, 409, "upload_busy", "", ""},
{"part too large", fmt.Errorf("submit: write upload part: %w", submit.ErrPartTooLarge), 413, "part_too_large", "", ""},
{"not owned", submit.ErrNotFound, 404, "not_found", "", ""},
{"no part store", submit.ErrUploadsUnavailable, 503, "uploads_unavailable", "", ""},
{"store did not answer", fmt.Errorf("%w: size of the context of sub-3: dial tcp: i/o timeout", submit.ErrStoreUnavailable),
503, "uploads_store_unavailable", "send the request again", "5"},
} {
fs := &fakeSubmissions{chunkErr: tc.err}
w := do(appSubAPI(fs).ExternalHandler(), "PUT", "/api/v1/me/submissions/sub-9/context/upload?offset=12", "abcd", nil)
@@ -75,6 +79,9 @@ func TestContextUploadErrors(t *testing.T) {
if tc.msg != "" && !strings.Contains(w.Body.String(), tc.msg) {
t.Errorf("%s: body %s does not say %q", tc.name, w.Body.String(), tc.msg)
}
if got := w.Header().Get("Retry-After"); got != tc.retry {
t.Errorf("%s: Retry-After = %q, want %q", tc.name, got, tc.retry)
}
}
}