Speed up artifact downloads

This commit is contained in:
npc0-hue
2026-09-03 11:27:19 +08:00
parent a82f1ff01a
commit 6311eb72ba
10 changed files with 142 additions and 83 deletions
+6 -2
View File
@@ -94,8 +94,12 @@ func ValidateArtifactContent(content domain.ArtifactContent) error {
if content.TotalSizeBytes <= 0 {
violations = append(violations, "totalSizeBytes must be positive")
}
if content.SizeBytes > MaxArtifactDownloadBytes {
violations = append(violations, fmt.Sprintf("sizeBytes must not exceed %d", MaxArtifactDownloadBytes))
maxContentBytes := int64(MaxArtifactDownloadBytes)
if !content.Partial {
maxContentBytes = MaxArtifactBytes
}
if content.SizeBytes > maxContentBytes {
violations = append(violations, fmt.Sprintf("sizeBytes must not exceed %d", maxContentBytes))
}
if int64(len(content.Payload)) != content.SizeBytes {
violations = append(violations, "payload size must match sizeBytes")