()
| 114 | } |
| 115 | |
| 116 | func fetchRemoteScripts() []models.Script { |
| 117 | client := &http.Client{Timeout: 10 * time.Second} |
| 118 | |
| 119 | // Try index-based loading (split files, concurrent) |
| 120 | for _, base := range []string{githubBaseURL, giteeBaseURL} { |
| 121 | scripts, err := fetchFromIndex(client, base) |
| 122 | if err != nil { |
| 123 | log.Printf("[builtin] remote index unavailable (%s), trying next source...", base) |
| 124 | continue |
| 125 | } |
| 126 | return scripts |
| 127 | } |
| 128 | |
| 129 | // Fallback to legacy single-file |
| 130 | for _, url := range []string{githubLegacyURL, giteeLegacyURL} { |
| 131 | scripts, err := fetchFromURL(client, url) |
| 132 | if err != nil { |
| 133 | log.Printf("[builtin] legacy source unavailable (%s), trying next...", url) |
| 134 | continue |
| 135 | } |
| 136 | return scripts |
| 137 | } |
| 138 | return nil |
| 139 | } |
| 140 | |
| 141 | func fetchFromIndex(client *http.Client, baseURL string) ([]models.Script, error) { |
| 142 | indexURL := baseURL + "/index.json" |
no test coverage detected