diff --git a/cmd/account/account_producer_extension_info_push.go b/cmd/account/account_producer_extension_info_push.go index 6e0362b..c4911d5 100644 --- a/cmd/account/account_producer_extension_info_push.go +++ b/cmd/account/account_producer_extension_info_push.go @@ -7,6 +7,7 @@ import ( "os" "path" "path/filepath" + "regexp" "strconv" "strings" @@ -336,6 +337,7 @@ func uploadImagesByDirectory(ctx context.Context, extensionId int, directory str } imagesLen := len(images) - 1 + re := regexp.MustCompile(`^(\d+)([_-][a-zA-Z0-9-_]+)?$`) for i, image := range images { if image.IsDir() { @@ -351,13 +353,20 @@ func uploadImagesByDirectory(ctx context.Context, extensionId int, directory str return fmt.Errorf("cannot upload image %s to extension: %w", image.Name(), err) } - priority, err := strconv.Atoi(fileName) + matches := re.FindStringSubmatch(fileName) - if err != nil { + if matches == nil { logging.FromContext(ctx).Warnf("Invalid image name %s, skipping", image.Name()) continue } + priority, err := strconv.Atoi(matches[1]) + + if err != nil { + logging.FromContext(ctx).Warnf("Unexpected error: \"%s\", skipping", err) + continue + } + apiImage.Priority = priority apiImage.Details[0].Activated = false apiImage.Details[0].Preview = false