lib/uplink: better diagnostics with invalid encryption access
Fixes #3841 Change-Id: I965b8fbb8fd221c740c2fc1421d66721c046f038
This commit is contained in:
parent
324fd410a0
commit
13baacc479
@ -42,6 +42,17 @@ func NewEncryptionAccessWithDefaultKey(defaultKey storj.Key) *EncryptionAccess {
|
|||||||
return ec
|
return ec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate returns an error if the EncryptionAccess is not valid to be used.
|
||||||
|
func (s *EncryptionAccess) validate() error {
|
||||||
|
if s == nil {
|
||||||
|
return errs.New("invalid nil encryption access")
|
||||||
|
}
|
||||||
|
if s.store == nil {
|
||||||
|
return errs.New("invalid encryption access: no store")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Store returns the underlying encryption store for the access context.
|
// Store returns the underlying encryption store for the access context.
|
||||||
func (s *EncryptionAccess) Store() *encryption.Store {
|
func (s *EncryptionAccess) Store() *encryption.Store {
|
||||||
return s.store
|
return s.store
|
||||||
|
@ -158,6 +158,10 @@ func (p *Project) GetBucketInfo(ctx context.Context, bucket string) (b storj.Buc
|
|||||||
func (p *Project) OpenBucket(ctx context.Context, bucketName string, access *EncryptionAccess) (b *Bucket, err error) {
|
func (p *Project) OpenBucket(ctx context.Context, bucketName string, access *EncryptionAccess) (b *Bucket, err error) {
|
||||||
defer mon.Task()(&ctx)(&err)
|
defer mon.Task()(&ctx)(&err)
|
||||||
|
|
||||||
|
if err := access.validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
bucketInfo, cfg, err := p.GetBucketInfo(ctx, bucketName)
|
bucketInfo, cfg, err := p.GetBucketInfo(ctx, bucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user