Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metadata parsing #1953

Merged
merged 4 commits into from
Jan 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions common/fe-ste-models.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package common
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"math"
"os"
Expand Down Expand Up @@ -110,7 +111,7 @@ type PartNumber uint32
type Version uint32
type Status uint32

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these be reverted?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*the comment changes specifically

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this formatting setting can be changed in GoLand.
File -> Settings -> Editor -> Code Style -> Go -> Other -> Add a leading space to comments should be unchecked.

var EDeleteSnapshotsOption = DeleteSnapshotsOption(0)

type DeleteSnapshotsOption uint8
Expand Down Expand Up @@ -145,7 +146,7 @@ func (d DeleteSnapshotsOption) ToDeleteSnapshotsOptionType() azblob.DeleteSnapsh
return azblob.DeleteSnapshotsOptionType(strings.ToLower(d.String()))
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var EPermanentDeleteOption = PermanentDeleteOption(3) // Default to "None"

type PermanentDeleteOption uint8
Expand Down Expand Up @@ -610,7 +611,7 @@ func (ft *FromTo) IsPropertyOnlyTransfer() bool {

var BenchmarkLmt = time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Enumerates the values for blob type.
type BlobType uint8

Expand Down Expand Up @@ -674,9 +675,11 @@ type TransferStatus int32 // Must be 32-bit for atomic operations; negative #s r
func (TransferStatus) NotStarted() TransferStatus { return TransferStatus(0) }

// TODO confirm whether this is actually needed
// Outdated:
// Transfer started & at least 1 chunk has successfully been transferred.
// Used to resume a transfer that started to avoid transferring all chunks thereby improving performance
//
// Outdated:
// Transfer started & at least 1 chunk has successfully been transferred.
// Used to resume a transfer that started to avoid transferring all chunks thereby improving performance
//
// Update(Jul 2020): This represents the state of transfer as soon as the file is scheduled.
func (TransferStatus) Started() TransferStatus { return TransferStatus(1) }

Expand Down Expand Up @@ -972,7 +975,7 @@ func (i *InvalidMetadataHandleOption) UnmarshalJSON(b []byte) error {
return i.Parse(s)
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const (
DefaultBlockBlobBlockSize = 8 * 1024 * 1024
MaxBlockBlobBlockSize = 4000 * 1024 * 1024
Expand Down Expand Up @@ -1076,12 +1079,11 @@ func StringToMetadata(metadataString string) (Metadata, error) {
metadataMap := Metadata{}
if len(metadataString) > 0 {
for _, keyAndValue := range strings.Split(metadataString, ";") { // key/value pairs are separated by ';'
kv := strings.Split(keyAndValue, "=") // key/value are separated by '='
// what if '=' not present?
if len(kv) != 2 {
return metadataMap, fmt.Errorf("invalid metadata string passed")
kEnd := strings.IndexByte(keyAndValue, '=')
adreed-msft marked this conversation as resolved.
Show resolved Hide resolved
if kEnd == -1 {
return nil, errors.New("invalid metadata; no value present with key")
}
metadataMap[kv[0]] = kv[1]
metadataMap[keyAndValue[:kEnd]] = keyAndValue[kEnd+1:]
}
}
return metadataMap, nil
Expand Down Expand Up @@ -1561,7 +1563,7 @@ func GetClientProvidedKey(options CpkOptions) azblob.ClientProvidedKeyOptions {
return ToClientProvidedKeyOptions(_cpkInfo, _cpkScopeInfo)
}

////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
type SetPropertiesFlags uint32 // [0000000000...32 times]

var ESetPropertiesFlags = SetPropertiesFlags(0)
Expand All @@ -1584,7 +1586,7 @@ func (op *SetPropertiesFlags) ShouldTransferBlobTags() bool {
return (*op)&ESetPropertiesFlags.SetBlobTags() == ESetPropertiesFlags.SetBlobTags()
}

////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////
type RehydratePriorityType uint8

var ERehydratePriorityType = RehydratePriorityType(0) // setting default as none
Expand Down