storj.io/uplink@v1.13.0/project_multipart.go (about)

     1  // Copyright (C) 2021 Storj Labs, Inc.
     2  // See LICENSE for copying information.
     3  
     4  package uplink
     5  
     6  import (
     7  	"context"
     8  	"io"
     9  	_ "unsafe" // for go:linkname
    10  
    11  	"storj.io/common/encryption"
    12  	"storj.io/common/paths"
    13  	"storj.io/common/pb"
    14  	"storj.io/common/storj"
    15  	"storj.io/uplink/private/eestream"
    16  	"storj.io/uplink/private/metaclient"
    17  )
    18  
    19  // dialMetainfoClient is exposing project.dialMetainfoClient method.
    20  //
    21  // NB: this is used with linkname in private/multipart.
    22  // It needs to be updated when this is updated.
    23  //
    24  //lint:ignore U1000, used with linkname
    25  //nolint:deadcode,unused
    26  //go:linkname dialMetainfoClient
    27  func dialMetainfoClient(ctx context.Context, project *Project) (_ *metaclient.Client, err error) {
    28  	return project.dialMetainfoClient(ctx)
    29  }
    30  
    31  // dialMetainfoClient is exposing project encryptionParameters field.
    32  //
    33  // NB: this is used with linkname in private/multipart.
    34  // It needs to be updated when this is updated.
    35  //
    36  //lint:ignore U1000, used with linkname
    37  //nolint:deadcode,unused
    38  //go:linkname encryptionParameters
    39  func encryptionParameters(project *Project) storj.EncryptionParameters {
    40  	return project.encryptionParameters
    41  }
    42  
    43  // segmentSize is exposing project segmentSize field.
    44  //
    45  // NB: this is used with linkname in private/multipart.
    46  // It needs to be updated when this is updated.
    47  //
    48  //lint:ignore U1000, used with linkname
    49  //nolint:deadcode,unused
    50  //go:linkname segmentSize
    51  func segmentSize(project *Project) int64 {
    52  	return project.segmentSize
    53  }
    54  
    55  // encryptPath is exposing helper method to encrypt path with project internals.
    56  //
    57  // NB: this is used with linkname in private/multipart.
    58  // It needs to be updated when this is updated.
    59  //
    60  //lint:ignore U1000, used with linkname
    61  //nolint:unused
    62  //go:linkname encryptPath
    63  func encryptPath(project *Project, bucket, key string) (paths.Encrypted, error) {
    64  	encStore := project.access.encAccess.Store
    65  	encPath, err := encryption.EncryptPathWithStoreCipher(bucket, paths.NewUnencrypted(key), encStore)
    66  	return encPath, err
    67  }
    68  
    69  // deriveContentKey is exposing helper method to derive content key with project internals.
    70  //
    71  // NB: this is used with linkname in private/multipart.
    72  // It needs to be updated when this is updated.
    73  //
    74  //lint:ignore U1000, used with linkname
    75  //nolint:unused
    76  //go:linkname deriveContentKey
    77  func deriveContentKey(project *Project, bucket, key string) (*storj.Key, error) {
    78  	encStore := project.access.encAccess.Store
    79  	derivedKey, err := encryption.DeriveContentKey(bucket, paths.NewUnencrypted(key), encStore)
    80  	return derivedKey, err
    81  }
    82  
    83  // ecPutSingleResult is exposing ec client PutSingleResult method.
    84  //
    85  // NB: this is used with linkname in private/multipart.
    86  // It needs to be updated when this is updated.
    87  //
    88  //lint:ignore U1000, used with linkname
    89  //nolint:deadcode,unused
    90  //go:linkname ecPutSingleResult
    91  func ecPutSingleResult(ctx context.Context, project *Project, limits []*pb.AddressedOrderLimit, privateKey storj.PiecePrivateKey,
    92  	rs eestream.RedundancyStrategy, data io.Reader) (results []*pb.SegmentPieceUploadResult, err error) {
    93  	return project.ec.PutSingleResult(ctx, limits, privateKey, rs, data)
    94  }
    95  
    96  // dialMetainfoDB is exposing project.dialMetainfoDB method.
    97  //
    98  // NB: this is used with linkname in private/multipart.
    99  // It needs to be updated when this is updated.
   100  //
   101  //lint:ignore U1000, used with linkname
   102  //nolint:unused
   103  //go:linkname dialMetainfoDB
   104  func dialMetainfoDB(ctx context.Context, project *Project) (_ *metaclient.DB, err error) {
   105  	return project.dialMetainfoDB(ctx)
   106  }