Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
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
4 changes: 2 additions & 2 deletions cmd/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (raw rawBenchmarkCmdArgs) appendVirtualDir(target, virtualDir string) (stri
p.BlobName = virtualDir
return p.String(), err

case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
p, err := sharefile.ParseURL(target)
if err != nil {
return "", fmt.Errorf("error parsing the url %s. Failed with error %s", target, err.Error())
Expand Down Expand Up @@ -229,7 +229,7 @@ func (raw rawBenchmarkCmdArgs) createCleanupJobArgs(benchmarkDest common.Resourc
switch InferArgumentLocation(rc.src) {
case common.ELocation.Blob():
rc.fromTo = common.EFromTo.BlobTrash().String()
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
rc.fromTo = common.EFromTo.FileTrash().String()
case common.ELocation.BlobFS():
rc.fromTo = common.EFromTo.BlobFSTrash().String()
Expand Down
2 changes: 1 addition & 1 deletion cmd/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func (raw *rawCopyCmdArgs) setMandatoryDefaults() {
}

func validateForceIfReadOnly(toForce bool, fromTo common.FromTo) error {
targetIsFiles := (fromTo.To() == common.ELocation.File() || fromTo.To() == common.ELocation.FileNFS()) ||
targetIsFiles := (fromTo.To() == common.ELocation.FileSMB() || fromTo.To() == common.ELocation.FileNFS()) ||
fromTo == common.EFromTo.FileTrash()
targetIsWindowsFS := fromTo.To() == common.ELocation.Local() &&
runtime.GOOS == "windows"
Expand Down
6 changes: 3 additions & 3 deletions cmd/copyEnumeratorInit.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func (cca *CookedCopyCmdArgs) createDstContainer(containerName string, dstWithSA
return nil
}
return err
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
fsc, _ := sc.FileServiceClient()
sc := fsc.NewShareClient(containerName)

Expand Down Expand Up @@ -614,7 +614,7 @@ func pathEncodeRules(path string, fromTo common.FromTo, disableAutoDecoding bool

// If downloading on Windows or uploading to files, encode unsafe characters.
if (loc == common.ELocation.Local() && !source && runtime.GOOS == "windows") ||
(!source && (loc == common.ELocation.File() || loc == common.ELocation.FileNFS())) {
(!source && (loc == common.ELocation.FileSMB() || loc == common.ELocation.FileNFS())) {
// invalidChars := `<>\/:"|?*` + string(0x00)

for k, c := range encodedInvalidCharacters {
Expand All @@ -625,7 +625,7 @@ func pathEncodeRules(path string, fromTo common.FromTo, disableAutoDecoding bool

// If uploading from Windows or downloading from files, decode unsafe chars if user enables decoding
} else if ((!source && fromTo.From() == common.ELocation.Local() && runtime.GOOS == "windows") ||
(!source && (fromTo.From() == common.ELocation.File() || fromTo.From() == common.ELocation.FileNFS()))) && !disableAutoDecoding {
(!source && (fromTo.From() == common.ELocation.FileSMB() || fromTo.From() == common.ELocation.FileNFS()))) && !disableAutoDecoding {

for encoded, c := range reverseEncodedChars {
for k, p := range pathParts {
Expand Down
2 changes: 1 addition & 1 deletion cmd/credentialUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func checkAuthSafeForTarget(ct common.CredentialType, resource, extraSuffixesAAD
common.ECredentialType.MDOAuthToken(),
common.ECredentialType.SharedKey():
// Files doesn't currently support OAuth, but it's a valid azure endpoint anyway, so it'll pass the check.
if resourceType != common.ELocation.Blob() && resourceType != common.ELocation.BlobFS() && resourceType != common.ELocation.File() && resourceType != common.ELocation.FileNFS() {
if resourceType != common.ELocation.Blob() && resourceType != common.ELocation.BlobFS() && resourceType != common.ELocation.FileSMB() && resourceType != common.ELocation.FileNFS() {
// There may be a reason for files->blob to specify this.
if resourceType == common.ELocation.Local() {
return nil
Expand Down
8 changes: 4 additions & 4 deletions cmd/flagsValidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,20 @@ func validateShareProtocolCompatibility(
return nil
}

direction := "from"
location, direction := "source", "from"
if !isSource {
direction = "to"
location, direction = "destination", "to"
}

// We can ignore the error if we fail to get the share properties.
shareProtocol, _ := getShareProtocolType(ctx, serviceClient, resource, protocol)

if shareProtocol == "SMB" && common.IsNFSCopy() {
return fmt.Errorf("The %s share has SMB protocol enabled. To copy %s a SMB share, use the appropriate --from-to flag value", direction, direction)
return fmt.Errorf("The %s share has SMB protocol enabled. To copy %s a SMB share, use the appropriate --from-to flag value", location, direction)
}

if shareProtocol == "NFS" && !common.IsNFSCopy() {
return fmt.Errorf("The %s share has NFS protocol enabled. To copy %s a NFS share, use the appropriate --from-to flag value", direction, direction)
return fmt.Errorf("The %s share has NFS protocol enabled. To copy %s a NFS share, use the appropriate --from-to flag value", location, direction)
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions cmd/jobsResume.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (rca resumeCmdArgs) getSourceAndDestinationServiceClients(
}

var fileSrcClientOptions any
if fromTo.From() == common.ELocation.File() || fromTo.From() == common.ELocation.FileNFS() {
if fromTo.From() == common.ELocation.FileSMB() || fromTo.From() == common.ELocation.FileNFS() {
fileSrcClientOptions = &common.FileClientOptions{
AllowTrailingDot: getJobDetailsResponse.TrailingDot.IsEnabled(), //Access the trailingDot option of the job
}
Expand All @@ -334,9 +334,9 @@ func (rca resumeCmdArgs) getSourceAndDestinationServiceClients(
}
options = createClientOptions(common.AzcopyCurrentJobLogger, srcCred, common.Iff(dstCredType.IsAzureOAuth(), reauthTok, nil))
var fileClientOptions any
if fromTo.To() == common.ELocation.File() || fromTo.To() == common.ELocation.FileNFS() {
if fromTo.To() == common.ELocation.FileSMB() || fromTo.To() == common.ELocation.FileNFS() {
fileClientOptions = &common.FileClientOptions{
AllowSourceTrailingDot: getJobDetailsResponse.TrailingDot.IsEnabled() && fromTo.From() == common.ELocation.File(),
AllowSourceTrailingDot: getJobDetailsResponse.TrailingDot.IsEnabled() && fromTo.From() == common.ELocation.FileSMB(),
AllowTrailingDot: getJobDetailsResponse.TrailingDot.IsEnabled(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (raw rawListCmdArgs) cook() (cookedListCmdArgs, error) {
// Only support listing for Azure locations
switch cooked.location {
case common.ELocation.Blob():
case common.ELocation.File(),common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
case common.ELocation.BlobFS():
break
default:
Expand Down
2 changes: 1 addition & 1 deletion cmd/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (cookedArgs cookedMakeCmdArgs) process() (err error) {
// print the ugly error if unexpected
return err
}
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
var shareClient *share.Client
shareClient, err = share.NewClientWithNoCredential(resourceURL, &share.ClientOptions{ClientOptions: options})
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions cmd/pathUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func DetermineLocationLevel(location string, locationType common.Location, sourc
return ELocationLevel.Object(), nil // we always benchmark to a subfolder, not the container root

case common.ELocation.Blob(),
common.ELocation.File(),
common.ELocation.FileSMB(),
common.ELocation.FileNFS(),
common.ELocation.BlobFS(),
common.ELocation.S3(),
Expand Down Expand Up @@ -125,7 +125,7 @@ func GetResourceRoot(resource string, location common.Location) (resourceBase st
return bURLParts.String(), nil

//noinspection GoNilness
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
fURLParts, err := filesas.ParseURL(resource)
if err != nil {
return resource, err
Expand Down Expand Up @@ -251,7 +251,7 @@ func splitAuthTokenFromResource(resource string, location common.Location) (reso
bURLParts.SAS = blobsas.QueryParameters{} // clear the SAS token and drop the raw, base URL
resourceBase = bURLParts.String()
return
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
var fURLParts filesas.URLParts
fURLParts, err = filesas.ParseURL(resource)
if err != nil {
Expand Down Expand Up @@ -325,7 +325,7 @@ func GetAccountRoot(resource common.ResourceString, location common.Location) (s
case common.ELocation.Local():
panic("attempted to get account root on local location")
case common.ELocation.Blob(),
common.ELocation.File(),
common.ELocation.FileSMB(),
common.ELocation.FileNFS(),
common.ELocation.BlobFS():
baseURL, err := resource.String()
Expand Down Expand Up @@ -355,7 +355,7 @@ func GetContainerName(path string, location common.Location) (string, error) {
case common.ELocation.Local():
panic("attempted to get container name on local location")
case common.ELocation.Blob(),
common.ELocation.File(),
common.ELocation.FileSMB(),
common.ELocation.FileNFS(),
common.ELocation.BlobFS():
bURLParts, err := blobsas.ParseURL(path)
Expand Down
2 changes: 1 addition & 1 deletion cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func init() {
switch srcLocationType {
case common.ELocation.Blob():
raw.fromTo = common.EFromTo.BlobTrash().String()
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
raw.fromTo = common.EFromTo.FileTrash().String()
case common.ELocation.BlobFS():
raw.fromTo = common.EFromTo.BlobFSTrash().String()
Expand Down
2 changes: 1 addition & 1 deletion cmd/setProperties.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func init() {
raw.fromTo = common.EFromTo.BlobNone().String()
case common.ELocation.BlobFS():
raw.fromTo = common.EFromTo.BlobFSNone().String()
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
raw.fromTo = common.EFromTo.FileNone().String()
default:
return fmt.Errorf("invalid source type %s. azcopy supports set-properties of blobs/files/adls gen2", srcLocationType.String())
Expand Down
8 changes: 4 additions & 4 deletions cmd/syncEnumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (cca *cookedSyncCmdArgs) initEnumerator(ctx context.Context) (enumerator *s

// Create Source Client.
var azureFileSpecificOptions any
if cca.fromTo.From() == common.ELocation.File() || cca.fromTo.From() == common.ELocation.FileNFS() {
if cca.fromTo.From() == common.ELocation.FileSMB() || cca.fromTo.From() == common.ELocation.FileNFS() {
azureFileSpecificOptions = &common.FileClientOptions{
AllowTrailingDot: cca.trailingDot == common.ETrailingDotOption.Enable(),
}
Expand All @@ -279,10 +279,10 @@ func (cca *cookedSyncCmdArgs) initEnumerator(ctx context.Context) (enumerator *s
}

// Create Destination client
if cca.fromTo.To() == common.ELocation.File() || cca.fromTo.To() == common.ELocation.FileNFS() {
if cca.fromTo.To() == common.ELocation.FileSMB() || cca.fromTo.To() == common.ELocation.FileNFS() {
azureFileSpecificOptions = &common.FileClientOptions{
AllowTrailingDot: cca.trailingDot == common.ETrailingDotOption.Enable(),
AllowSourceTrailingDot: (cca.trailingDot == common.ETrailingDotOption.Enable() && cca.fromTo.To() == common.ELocation.File()),
AllowSourceTrailingDot: (cca.trailingDot == common.ETrailingDotOption.Enable() && cca.fromTo.To() == common.ELocation.FileSMB()),
}
}

Expand Down Expand Up @@ -366,7 +366,7 @@ func (cca *cookedSyncCmdArgs) initEnumerator(ctx context.Context) (enumerator *s
// since only then can we know which local files definitely don't exist remotely
var deleteScheduler objectProcessor
switch cca.fromTo.To() {
case common.ELocation.Blob(), common.ELocation.File(), common.ELocation.FileNFS(), common.ELocation.BlobFS():
case common.ELocation.Blob(), common.ELocation.FileSMB(), common.ELocation.FileNFS(), common.ELocation.BlobFS():
deleter, err := newSyncDeleteProcessor(cca, fpo, copyJobTemplate.DstServiceClient)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/syncProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (b *remoteResourceDeleter) delete(object StoredObject) error {
defer b.folderManager.RecordChildDeleted(objURL)

_, err = blobClient.Delete(b.ctx, nil)
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
fsc, _ := sc.FileServiceClient()
fileClient := fsc.NewShareClient(b.containerName).NewRootDirectoryClient().NewFileClient(objectPath)

Expand Down Expand Up @@ -379,7 +379,7 @@ func (b *remoteResourceDeleter) delete(object StoredObject) error {
_, err = blobClient.Delete(b.ctx, nil)
return (err == nil)
}
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
fsc, _ := sc.FileServiceClient()
dirClient := fsc.NewShareClient(b.containerName).NewDirectoryClient(objectPath)
objURL, err = b.getObjectURL(dirClient.URL())
Expand Down
2 changes: 1 addition & 1 deletion cmd/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func InferArgumentLocation(arg string) common.Location {
case strings.Contains(host, ".blob"):
return common.ELocation.Blob()
case strings.Contains(host, ".file"):
return common.ELocation.File()
return common.ELocation.FileSMB()
case strings.Contains(host, ".dfs"):
return common.ELocation.BlobFS()
case strings.Contains(host, benchmarkSourceHost):
Expand Down
8 changes: 4 additions & 4 deletions cmd/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ func TestValidateArgumentLocation(t *testing.T) {
}{
// User does not specify location
{"https://test.blob.core.windows.net/container1", "", common.ELocation.Blob(), ""},
{"https://test.file.core.windows.net/container1", "", common.ELocation.File(), ""},
{"https://test.file.core.windows.net/container1", "", common.ELocation.FileSMB(), ""},
{"https://test.dfs.core.windows.net/container1", "", common.ELocation.BlobFS(), ""},
{"https://s3.amazonaws.com/bucket", "", common.ELocation.S3(), ""},
{"https://storage.cloud.google.com/bucket", "", common.ELocation.GCP(), ""},
{"https://privateendpoint.com/container1", "", common.ELocation.Unknown(), "the inferred location could not be identified, or is currently not supported"},
{"http://127.0.0.1:10000/devstoreaccount1/container1", "", common.ELocation.Unknown(), "the inferred location could not be identified, or is currently not supported"},

// User specifies location
{"https://privateendpoint.com/container1", "FILE", common.ELocation.File(), ""},
{"https://privateendpoint.com/container1", "FILE", common.ELocation.FileSMB(), ""},
{"http://127.0.0.1:10000/devstoreaccount1/container1", "BloB", common.ELocation.Blob(), ""},
{"https://test.file.core.windows.net/container1", "blobfs", common.ELocation.BlobFS(), ""}, // Tests that the endpoint does not really matter
{"https://privateendpoint.com/container1", "random", common.ELocation.Unknown(), "invalid --location value specified"},
Expand All @@ -51,7 +51,7 @@ func TestInferArgumentLocation(t *testing.T) {
expectedLocation common.Location
}{
{"https://test.blob.core.windows.net/container8", common.ELocation.Blob()},
{"https://test.file.core.windows.net/container23", common.ELocation.File()},
{"https://test.file.core.windows.net/container23", common.ELocation.FileSMB()},
{"https://test.dfs.core.windows.net/container45", common.ELocation.BlobFS()},
{"https://s3.amazonaws.com/bucket", common.ELocation.S3()},
{"https://storage.cloud.google.com/bucket", common.ELocation.GCP()},
Expand All @@ -63,5 +63,5 @@ func TestInferArgumentLocation(t *testing.T) {
for _, v := range test {
loc := InferArgumentLocation(v.src)
a.Equal(v.expectedLocation, loc)
}
}
}
6 changes: 3 additions & 3 deletions cmd/zc_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func InitResourceTraverser(resource common.ResourceString, resourceLocation comm
} else {
output = newBlobTraverser(r, bsc, ctx, opts)
}
case common.ELocation.File(), common.ELocation.FileNFS():
case common.ELocation.FileSMB(), common.ELocation.FileNFS():
// TODO (last service migration) : Remove dependency on URLs.
resourceURL, err := resource.FullURL()
if err != nil {
Expand All @@ -539,8 +539,8 @@ func InitResourceTraverser(resource common.ResourceString, resourceLocation comm
AllowTrailingDot: opts.TrailingDotOption.IsEnabled(),
}
var resLoc common.Location
if resourceLocation == common.ELocation.File() {
resLoc = common.ELocation.File()
if resourceLocation == common.ELocation.FileSMB() {
resLoc = common.ELocation.FileSMB()
} else {
resLoc = common.ELocation.FileNFS()
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/zt_pathUtils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
package cmd

import (
"testing"

"github.com/Azure/azure-storage-azcopy/v10/common"
"github.com/stretchr/testify/assert"
chk "gopkg.in/check.v1"
"testing"
)

type pathUtilsSuite struct{}
Expand Down Expand Up @@ -53,7 +54,7 @@ func TestStripQueryFromSaslessUrl(t *testing.T) {
for _, t := range tests {
loc := common.ELocation.Local()
if t.isRemote {
loc = common.ELocation.File()
loc = common.ELocation.FileSMB()
}
m, q := splitQueryFromSaslessResource(t.full, loc)
a.Equal(t.expectedMain, m)
Expand All @@ -67,4 +68,4 @@ func TestToReversedString(t *testing.T) {
a.Equal("1", traverser.toReversedString(1))
a.Equal("01", traverser.toReversedString(10))
a.Equal("54321", traverser.toReversedString(12345))
}
}
19 changes: 10 additions & 9 deletions cmd/zt_scenario_helpers_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ package cmd
import (
"context"
"fmt"
"io"
"net/url"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/appendblob"
Expand All @@ -39,14 +48,6 @@ import (
fileservice "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/service"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/share"
"github.com/stretchr/testify/assert"
"io"
"net/url"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"time"

gcpUtils "cloud.google.com/go/storage"
"github.com/minio/minio-go"
Expand Down Expand Up @@ -1022,7 +1023,7 @@ func getDefaultSetPropertiesRawInput(src string, params transferParams) rawCopyC
fromTo = common.EFromTo.BlobNone()
case common.ELocation.BlobFS():
fromTo = common.EFromTo.BlobFSNone()
case common.ELocation.File():
case common.ELocation.FileSMB():
fromTo = common.EFromTo.FileNone()
default:
panic(fmt.Sprintf("invalid source type %s to delete. azcopy support removing blobs/files/adls gen2", srcLocationType.String()))
Expand Down
5 changes: 3 additions & 2 deletions common/exclusiveStringMap.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
package common

import (
"github.com/pkg/errors"
"strings"
"sync"

"github.com/pkg/errors"
)

type ExclusiveStringMap struct {
Expand All @@ -36,7 +37,7 @@ func NewExclusiveStringMap(fromTo FromTo, goos string) *ExclusiveStringMap {

caseInsenstiveDownload := fromTo.IsDownload() &&
(strings.EqualFold(goos, "windows") || strings.EqualFold(goos, "darwin")) // download to case insensitive OS
caseSensitiveToRemote := fromTo.To() == ELocation.File() // upload to Windows-like cloud file system
caseSensitiveToRemote := fromTo.To() == ELocation.FileSMB() // upload to Windows-like cloud file system
insensitive := caseInsenstiveDownload || caseSensitiveToRemote
sensitive := !insensitive

Expand Down
Loading
Loading