32 lines
510 B
Go
32 lines
510 B
Go
|
package blob
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
type CloseBucketArgs struct {
|
||
|
BucketID BucketID
|
||
|
}
|
||
|
|
||
|
type CloseBucketReply struct {
|
||
|
}
|
||
|
|
||
|
func (s *Service) CloseBucket(ctx context.Context, args *CloseBucketArgs, reply *CloseBucketReply) error {
|
||
|
bucket, err := s.getOpenedBucket(args.BucketID)
|
||
|
if err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
if err := bucket.Close(); err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
s.buckets.Delete(args.BucketID)
|
||
|
|
||
|
*reply = CloseBucketReply{}
|
||
|
|
||
|
return nil
|
||
|
}
|