Skip to content

Commit

Permalink
op: Address review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
krnowak committed Jun 12, 2024
1 parent 162b6af commit bb5e414
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions op/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,17 @@ func Upload(ctx context.Context, blobServiceClient *service.Client, container, b
}

if opts == nil {
opts = &UploadOptions{}
opts = &UploadOptions{
Logger: noopLogger,
}
}

parallelism := 8 * runtime.NumCPU()
if opts.Parallelism > 0 {
parallelism = opts.Parallelism
}
overwrite := opts.Overwrite
logger := noopLogger
if opts.Logger != nil {
logger = opts.Logger
}
logger := opts.Logger

if err := ensureVHDSanity(vhd); err != nil {
return err
Expand Down Expand Up @@ -204,7 +203,7 @@ func ensureVHDSanity(vhd string) error {
// metadata. The parameter client is the Azure pageblob client
// representing a blob in a container, size is the size of the new
// page blob in bytes and parameter vhdMetadata is the custom metadata
// to be associacted with the page blob.
// to be associated with the page blob.
func createBlob(ctx context.Context, client *pageblob.Client, size int64, vhdMetadata *metadata.Metadata) error {
m, err := vhdMetadata.ToMap()
if err != nil {
Expand All @@ -219,7 +218,7 @@ func createBlob(ctx context.Context, client *pageblob.Client, size int64, vhdMet

// setBlobMD5Hash sets MD5 hash of the blob in its properties
func setBlobMD5Hash(ctx context.Context, client *blob.Client, vhdMetadata *metadata.Metadata) error {
if vhdMetadata.FileMetadata.MD5Hash == nil {
if vhdMetadata.FileMetadata == nil || len(vhdMetadata.FileMetadata.MD5Hash) == 0 {
return nil
}
buf := make([]byte, base64.StdEncoding.EncodedLen(len(vhdMetadata.FileMetadata.MD5Hash)))
Expand Down

0 comments on commit bb5e414

Please sign in to comment.