diff --git a/pkg/content/bucket.go b/pkg/content/bucket.go index 40186f64..ed9c6cca 100644 --- a/pkg/content/bucket.go +++ b/pkg/content/bucket.go @@ -25,6 +25,7 @@ var ( bucketKeyObjectContent = []byte("content") bucketKeyObjectBlob = []byte("blob") bucketKeyObjectLeases = []byte("leases") + bucketKeyObjectLabels = []byte("labels") bucketKeyVersion = []byte("v1") bucketKeyNamespace = []byte(accelerationServiceNamespace) diff --git a/pkg/content/content.go b/pkg/content/content.go index 2b3c90d2..97b8a9f2 100644 --- a/pkg/content/content.go +++ b/pkg/content/content.go @@ -122,6 +122,7 @@ func (content *Content) GC(ctx context.Context) error { // cleanLeases use lease to manage content blob, delete lease of content which should be gc func (content *Content) cleanLeases(ctx context.Context, size int64) error { ls, err := content.lm.List(ctx) + fmt.Println(len(ls)) if err != nil { return nil } @@ -136,6 +137,7 @@ func (content *Content) cleanLeases(ctx context.Context, size int64) error { return err } size -= blobsize + fmt.Println(size) return nil }); err != nil { return err @@ -148,6 +150,7 @@ func (content *Content) cleanLeases(ctx context.Context, size int64) error { } } ls, err = content.lm.List(ctx) + fmt.Println(len(ls)) if err != nil { return nil } @@ -222,5 +225,23 @@ func (content *Content) Abort(ctx context.Context, ref string) error { } func (content *Content) Writer(ctx context.Context, opts ...content.WriterOpt) (content.Writer, error) { - return content.store.Writer(ctx, opts...) + writer, err := content.store.Writer(ctx, opts...) + if err := content.db.Update(func(tx *bolt.Tx) error { + bucket := getBlobsBucket(tx) + // if can't find blob bucket, it maens content store is empty + if bucket == nil { + return nil + } + return bucket.ForEach(func(key, value []byte) error { + if subBucket := bucket.Bucket(key); subBucket != nil { + if subBucket.Bucket(bucketKeyObjectLabels) != nil { + return subBucket.DeleteBucket(bucketKeyObjectLabels) + } + } + return nil + }) + }); err != nil { + return nil, err + } + return writer, err }