Keep a single preview variant and verify read lock boundaries
Foundry Go checks / check (push) Successful in 5m13s
Foundry Go checks / check (pull_request) Successful in 3m56s

This commit is contained in:
2026-11-06 21:43:48 +08:00
parent 67765c17f4
commit 8abc79dc5b
5 changed files with 103 additions and 19 deletions
+3 -11
View File
@@ -12,7 +12,6 @@ import (
"image/color"
"image/jpeg"
"image/png"
"strconv"
"sync"
"golang.org/x/image/draw"
@@ -39,17 +38,10 @@ func previewWidth(variant, width string) (int, error) {
if variant == "" && width == "" {
return 0, nil
}
if variant != "preview" {
return 0, errors.New("invalid_asset_variant")
if variant == "preview" && (width == "" || width == "1024") {
return 1024, nil
}
if width == "" {
return 512, nil
}
n, err := strconv.Atoi(width)
if err != nil || (n != 256 && n != 512 && n != 1024 && n != 2048) {
return 0, errors.New("invalid_asset_variant")
}
return n, nil
return 0, errors.New("invalid_asset_variant")
}
// Cache only immutable bytes, after the caller checks current asset permission.