You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cleanup: use oci.NewStorage() for the ORAS_CACHE backing store #2312
Follow-on to #2008 (phase 2.1). The v2→v3 migration (#2002) has merged; this is one of the remaining deprecation-cleanup items.
Problem
cmd/oras/internal/option/cache.go:36 backs the ORAS_CACHE store with oci.New():
ociStore, err:=oci.New(opts.Root)
oci.New() maintains an index.json and is not safe for concurrent writes from multiple processes. A shared ORAS_CACHE directory used by two concurrent oras invocations can corrupt that index.
oci.NewStorage() does not maintain index.json and is process-safe. oras-go v3 ships it at content/oci/storage.go:67, and the library's own cache helper uses it for exactly this reason.
Change
Swap oci.New(opts.Root) for oci.NewStorage(opts.Root) in CachedTarget.
Net ~−2 LOC.
Notes
oci.Storage implements a narrower interface than oci.Store. Confirm nothing downstream of CachedTarget relies on the tag/index behaviour.
This is subsumed by the broader cleanup in the companion issue (adopting oras-go/content/cache wholesale), so the two may land in a single PR. Filed separately so the safety fix is tracked on its own.
Acceptance
ORAS_CACHE store is created with oci.NewStorage()
Existing cache tests pass; a test covers concurrent writes to a shared cache root
Activity