(ctx context.Context, client *http.Client, tag string)
| 240 | } |
| 241 | |
| 242 | func downloadReleaseProbeFile(ctx context.Context, client *http.Client, tag string) (bool, error) { |
| 243 | req, err := http.NewRequestWithContext(ctx, http.MethodHead, compileUpdateCheckProbeURLFunc(tag), nil) |
| 244 | if err != nil { |
| 245 | return false, fmt.Errorf("failed to create probe request for %s: %w", tag, err) |
| 246 | } |
| 247 | req.Header.Set("User-Agent", "gh-aw/"+GetVersion()) |
| 248 | |
| 249 | resp, err := client.Do(req) |
| 250 | if err != nil { |
| 251 | return false, fmt.Errorf("failed to download probe file for %s: %w", tag, err) |
| 252 | } |
| 253 | defer resp.Body.Close() |
| 254 | |
| 255 | switch resp.StatusCode { |
| 256 | case http.StatusOK: |
| 257 | return true, nil |
| 258 | case http.StatusNotFound: |
| 259 | return false, nil |
| 260 | default: |
| 261 | return false, fmt.Errorf("probe download for %s returned status %d", tag, resp.StatusCode) |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | func getCompileUpdateCheckFilePath() string { |
| 266 | return getCompileUpdateCheckFilePathFunc() |
no test coverage detected