Skip to content

Commit

Permalink
added new with context
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 committed Oct 23, 2023
1 parent d653def commit f3052d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions content/oci/deletableoci.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ func NewDeletableStore(root string) (*DeletableStore, error) {
return ds, nil
}

// NewDeletableStoreWithContext returns a new DeletableStore.
func NewDeletableStoreWithContext(ctx context.Context, root string) (*DeletableStore, error) {
store, err := NewWithContext(ctx, root)
if err != nil {
return nil, err
}
ds := &DeletableStore{
Store: store,
}
return ds, nil
}

// Fetch fetches the content identified by the descriptor.
func (ds *DeletableStore) Fetch(ctx context.Context, target ocispec.Descriptor) (io.ReadCloser, error) {
ds.lock.RLock()
Expand Down
2 changes: 1 addition & 1 deletion content/oci/deletableoci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestDeletableStore_basic(t *testing.T) {
func TestDeletableStore_FetchAndDelete(t *testing.T) {
// create a store
tempDir := t.TempDir()
s, err := NewDeletableStore(tempDir)
s, err := NewDeletableStoreWithContext(context.Background(), tempDir)
if err != nil {
t.Fatal("error =", err)
}
Expand Down

0 comments on commit f3052d2

Please sign in to comment.