fix(depot): include asset path in invalid-sha error
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,12 +17,10 @@ type manifestFile struct {
|
||||
} `yaml:"assets"`
|
||||
}
|
||||
|
||||
var sha256Pattern = regexp.MustCompile(`^[0-9a-f]{64}$`)
|
||||
|
||||
func ValidSHA(s string) bool {
|
||||
if len(s) != 64 {
|
||||
return false
|
||||
}
|
||||
match, _ := regexp.MatchString("^[0-9a-f]{64}$", s)
|
||||
return match
|
||||
return sha256Pattern.MatchString(s)
|
||||
}
|
||||
|
||||
func BlobKey(sha string) string {
|
||||
@@ -42,7 +40,7 @@ func ReferencedSHAs(dir string) (map[string]int64, error) {
|
||||
if entry.IsDir() {
|
||||
continue
|
||||
}
|
||||
if !hasYAMLExt(entry.Name()) {
|
||||
if filepath.Ext(entry.Name()) != ".yml" {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -60,7 +58,7 @@ func ReferencedSHAs(dir string) (map[string]int64, error) {
|
||||
|
||||
for _, asset := range manifest.Assets {
|
||||
if !ValidSHA(asset.SHA256) {
|
||||
return nil, fmt.Errorf("%s: invalid sha256 hash", entry.Name())
|
||||
return nil, fmt.Errorf("%s: asset %q: invalid sha256 %q", entry.Name(), asset.Path, asset.SHA256)
|
||||
}
|
||||
|
||||
// Keep the largest size for each sha
|
||||
@@ -76,7 +74,3 @@ func ReferencedSHAs(dir string) (map[string]int64, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func hasYAMLExt(name string) bool {
|
||||
return filepath.Ext(name) == ".yml" || filepath.Ext(name) == ".yaml"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user