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

[AzCopyV10][Bug] Uploading from top directory on linux fails when sub folder has the same name #2125

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 2 additions & 6 deletions cmd/copyEnumeratorHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@ package cmd
import (
"fmt"
"github.com/Azure/azure-pipeline-go/pipeline"
"github.com/Azure/azure-storage-azcopy/v10/common"
"github.com/Azure/azure-storage-azcopy/v10/jobsAdmin"
"math/rand"
"strings"

"github.com/Azure/azure-storage-azcopy/v10/common"
)

var EnumerationParallelism = 1
var EnumerationParallelStatFiles = false

// addTransfer accepts a new transfer, if the threshold is reached, dispatch a job part order.
func addTransfer(e *common.CopyJobPartOrderRequest, transfer common.CopyTransfer, cca *CookedCopyCmdArgs) error {
// Remove the source and destination roots from the path to save space in the plan files
transfer.Source = strings.TrimPrefix(transfer.Source, e.SourceRoot.Value)
transfer.Destination = strings.TrimPrefix(transfer.Destination, e.DestinationRoot.Value)
// Source and destination paths are and should be relative paths.

// dispatch the transfers once the number reaches NumOfFilesPerDispatchJobPart
// we do this so that in the case of large transfer, the transfer engine can get started
Expand Down
23 changes: 12 additions & 11 deletions cmd/copyEnumeratorHelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,24 @@ func newRemoteRes(url string) common.ResourceString {
return r
}

func (s *copyEnumeratorHelperTestSuite) TestAddTransferPathRootsTrimmed(c *chk.C) {
func (s *copyEnumeratorHelperTestSuite) TestRelativePath(c *chk.C) {
// setup
request := common.CopyJobPartOrderRequest{
SourceRoot: newLocalRes("a/b/"),
DestinationRoot: newLocalRes("y/z/"),
cca := CookedCopyCmdArgs{
Source: newLocalRes("a/b/"),
Destination: newLocalRes("y/z/"),
}

transfer := common.CopyTransfer{
Source: "a/b/c.txt",
Destination: "y/z/c.txt",
object := StoredObject{
name: "c.txt",
entityType: 1,
relativePath: "c.txt",
}

// execute
err := addTransfer(&request, transfer, &CookedCopyCmdArgs{})
srcRelPath := cca.MakeEscapedRelativePath(true, false, false, object)
destRelPath := cca.MakeEscapedRelativePath(false, true, false, object)

// assert
c.Assert(err, chk.IsNil)
c.Assert(request.Transfers.List[0].Source, chk.Equals, "c.txt")
c.Assert(request.Transfers.List[0].Destination, chk.Equals, "c.txt")
c.Assert(srcRelPath, chk.Equals, "/c.txt")
c.Assert(destRelPath, chk.Equals, "/c.txt")
}