handle recursive prefix properly for cp and sync as well
This commit is contained in:
@@ -128,7 +128,8 @@ func runListCmd(ctx *cli.Context) {
|
||||
for targetURL, targetConfig := range targetURLConfigMap {
|
||||
// if recursive strip off the "..."
|
||||
newTargetURL := stripRecursiveURL(targetURL)
|
||||
recursivePrefix := "" // is set when ... includes a directory, i.e. /path/to/dir... instead of path/to/dir/...
|
||||
// is set when ... includes a directory, i.e. /path/to/dir... instead of path/to/dir/...
|
||||
recursivePrefix := ""
|
||||
if isURLRecursive(targetURL) && !strings.HasSuffix(newTargetURL, string(filepath.Separator)) {
|
||||
recursivePrefix = filepath.Base(newTargetURL)
|
||||
}
|
||||
|
||||
@@ -212,7 +212,14 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan *cpURLs {
|
||||
}
|
||||
|
||||
// add `/` after trimming off `...` to emulate directories
|
||||
sourceURL = strings.TrimSuffix(stripRecursiveURL(sourceURL), "/") + "/"
|
||||
sourceURL = stripRecursiveURL(sourceURL)
|
||||
// is set when ... includes a directory, i.e. /path/to/dir... instead of path/to/dir/...
|
||||
recursivePrefix := ""
|
||||
if !strings.HasSuffix(sourceURL, string(filepath.Separator)) {
|
||||
recursivePrefix = filepath.Base(sourceURL)
|
||||
}
|
||||
sourceURL = strings.TrimSuffix(sourceURL, string(filepath.Separator)) + string(filepath.Separator)
|
||||
|
||||
sourceClient, err := source2Client(sourceURL)
|
||||
if err != nil {
|
||||
cpURLsCh <- &cpURLs{Error: iodine.New(err, nil)}
|
||||
@@ -286,7 +293,7 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan *cpURLs {
|
||||
|
||||
// Construct target path from recursive path of source without its prefix dir.
|
||||
newTargetURLParse := *targetURLParse
|
||||
newTargetURLParse.Path = filepath.Join(newTargetURLParse.Path,
|
||||
newTargetURLParse.Path = filepath.Join(newTargetURLParse.Path, recursivePrefix,
|
||||
strings.TrimPrefix(sourceContentParse.Path, filepath.Dir(sourceURLParse.Path)))
|
||||
cpURLsCh <- prepareCopyURLsTypeA(sourceContentParse.String(), newTargetURLParse.String())
|
||||
}
|
||||
|
||||
@@ -83,9 +83,7 @@ func doList(clnt client.Client, targetURL string, recursive bool, recursivePrefi
|
||||
// To be consistent we have to filter them out
|
||||
contentName = strings.TrimPrefix(contentName,
|
||||
strings.TrimSuffix(targetURL, string(filepath.Separator))+string(filepath.Separator))
|
||||
if recursivePrefix != "" {
|
||||
contentName = recursivePrefix + string(filepath.Separator) + contentName
|
||||
}
|
||||
contentName = filepath.Join(recursivePrefix, contentName)
|
||||
}
|
||||
contentCh.Content.Name = contentName
|
||||
console.Println(parseContent(contentCh.Content))
|
||||
|
||||
Reference in New Issue
Block a user