diff --git a/cmd/cp-url-syntax.go b/cmd/cp-url-syntax.go index e7bdfaf5..2602abdd 100644 --- a/cmd/cp-url-syntax.go +++ b/cmd/cp-url-syntax.go @@ -119,13 +119,13 @@ func checkCopySyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[stri if len(srcURLs) != 1 { fatalIf(errInvalidArgument().Trace(), "Invalid number of source arguments.") } - checkCopySyntaxTypeA(ctx, srcURLs[0], versionID, tgtURL, encKeyDB, isMvCmd, timeRef) + checkCopySyntaxTypeA(ctx, srcURLs[0], versionID, tgtURL, encKeyDB, isZip, isMvCmd, timeRef) case copyURLsTypeB: // File -> Folder. // Check source. if len(srcURLs) != 1 { fatalIf(errInvalidArgument().Trace(), "Invalid number of source arguments.") } - checkCopySyntaxTypeB(ctx, srcURLs[0], versionID, tgtURL, encKeyDB, isMvCmd, timeRef) + checkCopySyntaxTypeB(ctx, srcURLs[0], versionID, tgtURL, encKeyDB, isZip, isMvCmd, timeRef) case copyURLsTypeC: // Folder... -> Folder. checkCopySyntaxTypeC(ctx, srcURLs, tgtURL, isRecursive, isZip, encKeyDB, isMvCmd, timeRef) case copyURLsTypeD: // File1...FileN -> Folder. @@ -141,8 +141,8 @@ func checkCopySyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[stri } // checkCopySyntaxTypeA verifies if the source and target are valid file arguments. -func checkCopySyntaxTypeA(ctx context.Context, srcURL, versionID string, tgtURL string, keys map[string][]prefixSSEPair, isMvCmd bool, timeRef time.Time) { - _, srcContent, err := url2Stat(ctx, srcURL, versionID, false, keys, timeRef, false) +func checkCopySyntaxTypeA(ctx context.Context, srcURL, versionID string, tgtURL string, keys map[string][]prefixSSEPair, isZip, isMvCmd bool, timeRef time.Time) { + _, srcContent, err := url2Stat(ctx, srcURL, versionID, false, keys, timeRef, isZip) fatalIf(err.Trace(srcURL), "Unable to stat source `"+srcURL+"`.") if !srcContent.Type.IsRegular() { @@ -151,8 +151,8 @@ func checkCopySyntaxTypeA(ctx context.Context, srcURL, versionID string, tgtURL } // checkCopySyntaxTypeB verifies if the source is a valid file and target is a valid folder. -func checkCopySyntaxTypeB(ctx context.Context, srcURL, versionID string, tgtURL string, keys map[string][]prefixSSEPair, isMvCmd bool, timeRef time.Time) { - _, srcContent, err := url2Stat(ctx, srcURL, versionID, false, keys, timeRef, false) +func checkCopySyntaxTypeB(ctx context.Context, srcURL, versionID string, tgtURL string, keys map[string][]prefixSSEPair, isZip, isMvCmd bool, timeRef time.Time) { + _, srcContent, err := url2Stat(ctx, srcURL, versionID, false, keys, timeRef, isZip) fatalIf(err.Trace(srcURL), "Unable to stat source `"+srcURL+"`.") if !srcContent.Type.IsRegular() { diff --git a/cmd/cp-url.go b/cmd/cp-url.go index 302839c1..1599d548 100644 --- a/cmd/cp-url.go +++ b/cmd/cp-url.go @@ -69,7 +69,7 @@ func guessCopyURLType(ctx context.Context, o prepareCopyURLsOpts) (copyURLsType, // If recursion is ON, it is type C. // If source is a folder, it is Type C. - if sourceContent.Type.IsDir() || o.isRecursive || o.isZip { + if sourceContent.Type.IsDir() || o.isRecursive { return copyURLsTypeC, "", nil } @@ -91,13 +91,13 @@ func guessCopyURLType(ctx context.Context, o prepareCopyURLsOpts) (copyURLsType, // SINGLE SOURCE - Type A: copy(f, f) -> copy(f, f) // prepareCopyURLsTypeA - prepares target and source clientURLs for copying. -func prepareCopyURLsTypeA(ctx context.Context, sourceURL, sourceVersion string, targetURL string, encKeyDB map[string][]prefixSSEPair) URLs { +func prepareCopyURLsTypeA(ctx context.Context, sourceURL, sourceVersion string, targetURL string, encKeyDB map[string][]prefixSSEPair, isZip bool) URLs { // Extract alias before fiddling with the clientURL. sourceAlias, _, _ := mustExpandAlias(sourceURL) // Find alias and expanded clientURL. targetAlias, targetURL, _ := mustExpandAlias(targetURL) - _, sourceContent, err := url2Stat(ctx, sourceURL, sourceVersion, false, encKeyDB, time.Time{}, false) + _, sourceContent, err := url2Stat(ctx, sourceURL, sourceVersion, false, encKeyDB, time.Time{}, isZip) if err != nil { // Source does not exist or insufficient privileges. return URLs{Error: err.Trace(sourceURL)} @@ -124,13 +124,13 @@ func makeCopyContentTypeA(sourceAlias string, sourceContent *ClientContent, targ // SINGLE SOURCE - Type B: copy(f, d) -> copy(f, d/f) -> A // prepareCopyURLsTypeB - prepares target and source clientURLs for copying. -func prepareCopyURLsTypeB(ctx context.Context, sourceURL, sourceVersion string, targetURL string, encKeyDB map[string][]prefixSSEPair) URLs { +func prepareCopyURLsTypeB(ctx context.Context, sourceURL, sourceVersion string, targetURL string, encKeyDB map[string][]prefixSSEPair, isZip bool) URLs { // Extract alias before fiddling with the clientURL. sourceAlias, _, _ := mustExpandAlias(sourceURL) // Find alias and expanded clientURL. targetAlias, targetURL, _ := mustExpandAlias(targetURL) - _, sourceContent, err := url2Stat(ctx, sourceURL, sourceVersion, false, encKeyDB, time.Time{}, false) + _, sourceContent, err := url2Stat(ctx, sourceURL, sourceVersion, false, encKeyDB, time.Time{}, isZip) if err != nil { // Source does not exist or insufficient privileges. return URLs{Error: err.Trace(sourceURL)} @@ -241,9 +241,9 @@ func prepareCopyURLs(ctx context.Context, o prepareCopyURLsOpts) chan URLs { switch cpType { case copyURLsTypeA: - copyURLsCh <- prepareCopyURLsTypeA(ctx, o.sourceURLs[0], cpVersion, o.targetURL, o.encKeyDB) + copyURLsCh <- prepareCopyURLsTypeA(ctx, o.sourceURLs[0], cpVersion, o.targetURL, o.encKeyDB, o.isZip) case copyURLsTypeB: - copyURLsCh <- prepareCopyURLsTypeB(ctx, o.sourceURLs[0], cpVersion, o.targetURL, o.encKeyDB) + copyURLsCh <- prepareCopyURLsTypeB(ctx, o.sourceURLs[0], cpVersion, o.targetURL, o.encKeyDB, o.isZip) case copyURLsTypeC: for cURLs := range prepareCopyURLsTypeC(ctx, o.sourceURLs[0], o.targetURL, o.isRecursive, o.isZip, o.timeRef, o.encKeyDB) { copyURLsCh <- cURLs