Skip to content

Commit

Permalink
fix: update lease in commit
Browse files Browse the repository at this point in the history
To make leaseCache is synchronized with local storage before read each blob.

Signed-off-by: Yadong Ding <ding_yadong@foxmail.com>
  • Loading branch information
Desiki-high committed Aug 19, 2023
1 parent a6bf3b3 commit deed9db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,17 @@ func (content *Content) Abort(ctx context.Context, ref string) error {

func (content *Content) Writer(ctx context.Context, opts ...content.WriterOpt) (content.Writer, error) {
writer, err := content.store.Writer(ctx, opts...)
return &localWriter{writer}, err
return &localWriter{writer, content}, err
}

// localWriter wrap the content.Writer
type localWriter struct {
content.Writer
content *Content
}

func (localWriter localWriter) Commit(ctx context.Context, size int64, expected digest.Digest, opts ...content.Opt) error {
// we don't write any lables, drop the opts
localWriter.content.updateLease(&expected)
return localWriter.Writer.Commit(ctx, size, expected)
}

0 comments on commit deed9db

Please sign in to comment.