MCPcopy Index your code
hub / github.com/jetify-com/devbox / fetchNarInfoStatusFromS3

Function fetchNarInfoStatusFromS3

internal/devpkg/narinfo_cache.go:285–318  ·  view source on GitHub ↗
(
	ctx context.Context,
	uri string,
	hash string,
)

Source from the content-addressed store, hash-verified

283}
284
285func 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
320var nixCacheIsConfigured = goutil.OnceValueWithContext(nixcache.IsConfigured)
321

Callers 2

AreAllOutputsInCacheMethod · 0.85

Calls 3

S3ClientFunction · 0.92
GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected