Skip to content

cleanup: use oci.NewStorage() for the ORAS_CACHE backing store #2312

Description

@TerryHowe

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

  1. added this to the future milestone on Nov 4, 2026
  2. added
    enhancement
    go
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgo

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions