diff --git a/common/clientFactory.go b/common/clientFactory.go index 6271cd284..9de9be822 100644 --- a/common/clientFactory.go +++ b/common/clientFactory.go @@ -222,19 +222,14 @@ func CreatePageBlobClient(u string, credInfo CredentialInfo, credOpOptions *Cred ///////////////////////////////////////////////// FILE FUNCTIONS ///////////////////////////////////////////////// func CreateFileServiceClient(u string, credInfo CredentialInfo, credOpOptions *CredentialOpOptions, options azcore.ClientOptions, trailingDot *TrailingDotOption, from *Location) *fileservice.Client { - var allowTrailingDot, allowSourceTrailingDot *bool - if trailingDot != nil && *trailingDot == trailingDot.Enable() { - allowTrailingDot = to.Ptr(true) - } - if from != nil && *from == ELocation.File() { - allowSourceTrailingDot = to.Ptr(true) - } + allowTrailingDot := trailingDot != nil && *trailingDot == trailingDot.Enable() + allowSourceTrailingDot := allowTrailingDot && from != nil && *from == ELocation.File() callbacks := newClientCallbacks[fileservice.Client, sharefile.SharedKeyCredential]{ TokenCredential: func(u string, tc azcore.TokenCredential, options azcore.ClientOptions) (*fileservice.Client, error) { return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType) }, NoCredential: func(u string, options azcore.ClientOptions) (*fileservice.Client, error) { - return fileservice.NewClientWithNoCredential(u, &fileservice.ClientOptions{ClientOptions: options, AllowTrailingDot: allowTrailingDot, AllowSourceTrailingDot: allowSourceTrailingDot}) + return fileservice.NewClientWithNoCredential(u, &fileservice.ClientOptions{ClientOptions: options, AllowTrailingDot: to.Ptr(allowTrailingDot), AllowSourceTrailingDot: to.Ptr(allowSourceTrailingDot)}) }, SharedKeyCredential: func(u string, sharedKey *sharefile.SharedKeyCredential, options azcore.ClientOptions) (*fileservice.Client, error) { return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType) @@ -248,19 +243,14 @@ func CreateFileServiceClient(u string, credInfo CredentialInfo, credOpOptions *C } func CreateShareClient(u string, credInfo CredentialInfo, credOpOptions *CredentialOpOptions, options azcore.ClientOptions, trailingDot *TrailingDotOption, from *Location) *share.Client { - var allowTrailingDot, allowSourceTrailingDot *bool - if trailingDot != nil && *trailingDot == trailingDot.Enable() { - allowTrailingDot = to.Ptr(true) - } - if from != nil && *from == ELocation.File() { - allowSourceTrailingDot = to.Ptr(true) - } + allowTrailingDot := trailingDot != nil && *trailingDot == trailingDot.Enable() + allowSourceTrailingDot := allowTrailingDot && from != nil && *from == ELocation.File() callbacks := newClientCallbacks[share.Client, sharefile.SharedKeyCredential]{ TokenCredential: func(u string, tc azcore.TokenCredential, options azcore.ClientOptions) (*share.Client, error) { return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType) }, NoCredential: func(u string, options azcore.ClientOptions) (*share.Client, error) { - return share.NewClientWithNoCredential(u, &share.ClientOptions{ClientOptions: options, AllowTrailingDot: allowTrailingDot, AllowSourceTrailingDot: allowSourceTrailingDot}) + return share.NewClientWithNoCredential(u, &share.ClientOptions{ClientOptions: options, AllowTrailingDot: to.Ptr(allowTrailingDot), AllowSourceTrailingDot: to.Ptr(allowSourceTrailingDot)}) }, SharedKeyCredential: func(u string, sharedKey *sharefile.SharedKeyCredential, options azcore.ClientOptions) (*share.Client, error) { return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType) @@ -274,19 +264,14 @@ func CreateShareClient(u string, credInfo CredentialInfo, credOpOptions *Credent } func CreateShareFileClient(u string, credInfo CredentialInfo, credOpOptions *CredentialOpOptions, options azcore.ClientOptions, trailingDot *TrailingDotOption, from *Location) *sharefile.Client { - var allowTrailingDot, allowSourceTrailingDot *bool - if trailingDot != nil && *trailingDot == trailingDot.Enable() { - allowTrailingDot = to.Ptr(true) - } - if from != nil && *from == ELocation.File() { - allowSourceTrailingDot = to.Ptr(true) - } + allowTrailingDot := trailingDot != nil && *trailingDot == trailingDot.Enable() + allowSourceTrailingDot := allowTrailingDot && from != nil && *from == ELocation.File() callbacks := newClientCallbacks[sharefile.Client, sharefile.SharedKeyCredential]{ TokenCredential: func(u string, tc azcore.TokenCredential, options azcore.ClientOptions) (*sharefile.Client, error) { return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType) }, NoCredential: func(u string, options azcore.ClientOptions) (*sharefile.Client, error) { - return sharefile.NewClientWithNoCredential(u, &sharefile.ClientOptions{ClientOptions: options, AllowTrailingDot: allowTrailingDot, AllowSourceTrailingDot: allowSourceTrailingDot}) + return sharefile.NewClientWithNoCredential(u, &sharefile.ClientOptions{ClientOptions: options, AllowTrailingDot: to.Ptr(allowTrailingDot), AllowSourceTrailingDot: to.Ptr(allowSourceTrailingDot)}) }, SharedKeyCredential: func(u string, sharedKey *sharefile.SharedKeyCredential, options azcore.ClientOptions) (*sharefile.Client, error) { return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType) @@ -300,19 +285,14 @@ func CreateShareFileClient(u string, credInfo CredentialInfo, credOpOptions *Cre } func CreateShareDirectoryClient(u string, credInfo CredentialInfo, credOpOptions *CredentialOpOptions, options azcore.ClientOptions, trailingDot *TrailingDotOption, from *Location) *sharedirectory.Client { - var allowTrailingDot, allowSourceTrailingDot *bool - if trailingDot != nil && *trailingDot == trailingDot.Enable() { - allowTrailingDot = to.Ptr(true) - } - if from != nil && *from == ELocation.File() { - allowSourceTrailingDot = to.Ptr(true) - } + allowTrailingDot := trailingDot != nil && *trailingDot == trailingDot.Enable() + allowSourceTrailingDot := allowTrailingDot && from != nil && *from == ELocation.File() callbacks := newClientCallbacks[sharedirectory.Client, sharefile.SharedKeyCredential]{ TokenCredential: func(u string, tc azcore.TokenCredential, options azcore.ClientOptions) (*sharedirectory.Client, error) { return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType) }, NoCredential: func(u string, options azcore.ClientOptions) (*sharedirectory.Client, error) { - return sharedirectory.NewClientWithNoCredential(u, &sharedirectory.ClientOptions{ClientOptions: options, AllowTrailingDot: allowTrailingDot, AllowSourceTrailingDot: allowSourceTrailingDot}) + return sharedirectory.NewClientWithNoCredential(u, &sharedirectory.ClientOptions{ClientOptions: options, AllowTrailingDot: to.Ptr(allowTrailingDot), AllowSourceTrailingDot: to.Ptr(allowSourceTrailingDot)}) }, SharedKeyCredential: func(u string, sharedKey *sharefile.SharedKeyCredential, options azcore.ClientOptions) (*sharedirectory.Client, error) { return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType) diff --git a/common/environment.go b/common/environment.go index f81333cf9..5ef2b2206 100644 --- a/common/environment.go +++ b/common/environment.go @@ -319,7 +319,7 @@ func (EnvironmentVariable) CredentialType() EnvironmentVariable { func (EnvironmentVariable) DefaultServiceApiVersion() EnvironmentVariable { return EnvironmentVariable{ Name: "AZCOPY_DEFAULT_SERVICE_API_VERSION", - DefaultValue: "2020-10-02", + DefaultValue: "2022-11-02", Description: "Overrides the service API version so that AzCopy could accommodate custom environments such as Azure Stack.", } } diff --git a/ste/mgr-JobPartMgr.go b/ste/mgr-JobPartMgr.go index de698e842..a33e6c2a1 100644 --- a/ste/mgr-JobPartMgr.go +++ b/ste/mgr-JobPartMgr.go @@ -138,7 +138,7 @@ func NewClientOptions(retry policy.RetryOptions, telemetry policy.TelemetryOptio log.RequestLogOptions.SyslogDisabled = common.IsForceLoggingDisabled() perCallPolicies := []policy.Policy{azruntime.NewRequestIDPolicy()} // TODO : Default logging policy is not equivalent to old one. tracing HTTP request - perRetryPolicies := []policy.Policy{newRetryNotificationPolicy(), newVersionPolicy(), newColdTierPolicy(), newTrailingDotPolicy(), newLogPolicy(log), newStatsPolicy(statsAcc)} + perRetryPolicies := []policy.Policy{newRetryNotificationPolicy(), newVersionPolicy(), newColdTierPolicy(), newLogPolicy(log), newStatsPolicy(statsAcc)} return azcore.ClientOptions{ //APIVersion: , diff --git a/ste/xferVersionPolicy.go b/ste/xferVersionPolicy.go index 5381e7c38..d254bd035 100644 --- a/ste/xferVersionPolicy.go +++ b/ste/xferVersionPolicy.go @@ -62,18 +62,4 @@ func (r *coldTierPolicy) Do(req *policy.Request) (*http.Response, error) { req.Raw().Header["x-ms-version"] = []string{"2021-12-02"} } return req.Next() -} - -type trailingDotPolicy struct { -} - -func newTrailingDotPolicy() policy.Policy { - return &trailingDotPolicy{} -} - -func (r *trailingDotPolicy) Do(req *policy.Request) (*http.Response, error) { - if len(req.Raw().Header["x-ms-allow-trailing-dot"]) > 0 || len(req.Raw().Header["x-ms-source-allow-trailing-dot"]) > 0 { - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} - } - return req.Next() } \ No newline at end of file