mirror of
https://github.com/kopia/kopia.git
synced 2026-03-13 11:46:55 -04:00
blob: check that GCS/S3 bucket is present when the storage is opened
This commit is contained in:
@@ -267,6 +267,11 @@ func New(ctx context.Context, opt *Options) (blob.Storage, error) {
|
||||
return nil, errors.New("bucket name must be specified")
|
||||
}
|
||||
|
||||
// make sure the bucket exists
|
||||
if _, err := cli.Bucket(opt.BucketName).Attrs(ctx); err != nil {
|
||||
return nil, errors.Wrap(err, "unable to read bucket")
|
||||
}
|
||||
|
||||
return &gcsStorage{
|
||||
Options: *opt,
|
||||
ctx: ctx,
|
||||
|
||||
@@ -233,6 +233,15 @@ func New(ctx context.Context, opt *Options) (blob.Storage, error) {
|
||||
downloadThrottler := iothrottler.NewIOThrottlerPool(toBandwidth(opt.MaxDownloadSpeedBytesPerSecond))
|
||||
uploadThrottler := iothrottler.NewIOThrottlerPool(toBandwidth(opt.MaxUploadSpeedBytesPerSecond))
|
||||
|
||||
ok, err := cli.BucketExistsWithContext(ctx, opt.BucketName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to determine if bucket %q exists", opt.BucketName)
|
||||
}
|
||||
|
||||
if !ok {
|
||||
return nil, errors.Errorf("bucket %q does not exist", opt.BucketName)
|
||||
}
|
||||
|
||||
return &s3Storage{
|
||||
Options: *opt,
|
||||
ctx: ctx,
|
||||
|
||||
Reference in New Issue
Block a user