Skip to content

Commit

Permalink
[AzCopyV10][Bug] Uploading from top directory on linux fails when sub…
Browse files Browse the repository at this point in the history
… folder has the same name (#2125)

* Adding TODOs and bug fix seen with linux subfolders

* Add test for relative path and commented out old test

* Removed TODOs and cleaned up comments
  • Loading branch information
siminsavani-msft committed Mar 29, 2023
1 parent 6653755 commit 6770682
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
8 changes: 2 additions & 6 deletions cmd/copyEnumeratorHelper.go
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
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")
}

0 comments on commit 6770682

Please sign in to comment.