From 25e90db428e2cd5e6c799d5771715e4178dbfef7 Mon Sep 17 00:00:00 2001 From: Yadong Ding Date: Sun, 6 Aug 2023 11:32:25 +0800 Subject: [PATCH] feat: add localWriter We add localWriter to wrap writer in the content store to make sure not to write any labels in boltdb. In that case, we can make gc work well with the lease. Signed-off-by: Yadong Ding --- pkg/content/content.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/content/content.go b/pkg/content/content.go index 92b612a3..f544c57f 100644 --- a/pkg/content/content.go +++ b/pkg/content/content.go @@ -162,36 +162,37 @@ 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{ + return &localWriter{ writer: writer, }, err } -type LocalWriter struct { +// localWriter wrap the content.Writer +type localWriter struct { writer content.Writer } -func (localWriter *LocalWriter) Close() error { +func (localWriter *localWriter) Close() error { return localWriter.writer.Close() } -func (localWriter *LocalWriter) Write(p []byte) (int, error) { +func (localWriter *localWriter) Write(p []byte) (int, error) { return localWriter.writer.Write(p) } -func (localWriter *LocalWriter) Digest() digest.Digest { +func (localWriter *localWriter) Digest() digest.Digest { return localWriter.writer.Digest() } -func (localWriter *LocalWriter) Truncate(size int64) error { +func (localWriter *localWriter) Truncate(size int64) error { return localWriter.writer.Truncate(size) } -func (localWriter *LocalWriter) Commit(ctx context.Context, size int64, expected digest.Digest, opts ...content.Opt) error { +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 return localWriter.writer.Commit(ctx, size, expected) } -func (localWriter *LocalWriter) Status() (st content.Status, err error) { +func (localWriter *localWriter) Status() (st content.Status, err error) { return localWriter.writer.Status() }