Skip to content

Commit 6770682

Browse files
[AzCopyV10][Bug] Uploading from top directory on linux fails when sub 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
1 parent 6653755 commit 6770682

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

cmd/copyEnumeratorHelper.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@ package cmd
33
import (
44
"fmt"
55
"github.com/Azure/azure-pipeline-go/pipeline"
6+
"github.com/Azure/azure-storage-azcopy/v10/common"
67
"github.com/Azure/azure-storage-azcopy/v10/jobsAdmin"
78
"math/rand"
8-
"strings"
9-
10-
"github.com/Azure/azure-storage-azcopy/v10/common"
119
)
1210

1311
var EnumerationParallelism = 1
1412
var EnumerationParallelStatFiles = false
1513

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

2218
// dispatch the transfers once the number reaches NumOfFilesPerDispatchJobPart
2319
// we do this so that in the case of large transfer, the transfer engine can get started

cmd/copyEnumeratorHelper_test.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,24 @@ func newRemoteRes(url string) common.ResourceString {
4141
return r
4242
}
4343

44-
func (s *copyEnumeratorHelperTestSuite) TestAddTransferPathRootsTrimmed(c *chk.C) {
44+
func (s *copyEnumeratorHelperTestSuite) TestRelativePath(c *chk.C) {
4545
// setup
46-
request := common.CopyJobPartOrderRequest{
47-
SourceRoot: newLocalRes("a/b/"),
48-
DestinationRoot: newLocalRes("y/z/"),
46+
cca := CookedCopyCmdArgs{
47+
Source: newLocalRes("a/b/"),
48+
Destination: newLocalRes("y/z/"),
4949
}
5050

51-
transfer := common.CopyTransfer{
52-
Source: "a/b/c.txt",
53-
Destination: "y/z/c.txt",
51+
object := StoredObject{
52+
name: "c.txt",
53+
entityType: 1,
54+
relativePath: "c.txt",
5455
}
5556

5657
// execute
57-
err := addTransfer(&request, transfer, &CookedCopyCmdArgs{})
58+
srcRelPath := cca.MakeEscapedRelativePath(true, false, false, object)
59+
destRelPath := cca.MakeEscapedRelativePath(false, true, false, object)
5860

5961
// assert
60-
c.Assert(err, chk.IsNil)
61-
c.Assert(request.Transfers.List[0].Source, chk.Equals, "c.txt")
62-
c.Assert(request.Transfers.List[0].Destination, chk.Equals, "c.txt")
62+
c.Assert(srcRelPath, chk.Equals, "/c.txt")
63+
c.Assert(destRelPath, chk.Equals, "/c.txt")
6364
}

0 commit comments

Comments
 (0)