( ctx context.Context, uri string, hash string, )
| 283 | } |
| 284 | |
| 285 | func fetchNarInfoStatusFromS3( |
| 286 | ctx context.Context, |
| 287 | uri string, |
| 288 | hash string, |
| 289 | ) (bool, error) { |
| 290 | key := fmt.Sprintf("%s/%s", uri, hash) |
| 291 | fetch, _ := narInfoStatusFnCache.LoadOrStore(key, sync.OnceValues( |
| 292 | func() (bool, error) { |
| 293 | s3Client, err := nixcache.S3Client(ctx) |
| 294 | if err != nil { |
| 295 | return false, err |
| 296 | } |
| 297 | |
| 298 | bucketURI, err := url.Parse(uri) |
| 299 | if err != nil { |
| 300 | return false, errors.WithStack(err) |
| 301 | } |
| 302 | |
| 303 | _, err = s3Client.GetObject(ctx, |
| 304 | &s3.GetObjectInput{ |
| 305 | Bucket: aws.String(bucketURI.Hostname()), |
| 306 | Key: aws.String(hash + ".narinfo"), |
| 307 | }, |
| 308 | func(o *s3.Options) { |
| 309 | if bucketURI.Query().Get("region") != "" { |
| 310 | o.Region = bucketURI.Query().Get("region") |
| 311 | } |
| 312 | }, |
| 313 | ) |
| 314 | return err == nil, nil |
| 315 | }, |
| 316 | )) |
| 317 | return fetch.(func() (bool, error))() |
| 318 | } |
| 319 | |
| 320 | var nixCacheIsConfigured = goutil.OnceValueWithContext(nixcache.IsConfigured) |
| 321 |
no test coverage detected