Merge pull request #1332 from harshavardhana/cp
cp: Fix cp command behavior for s3/bucketname/prefix... operations
This commit is contained in:
@@ -290,11 +290,10 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan copyURLs {
|
||||
}
|
||||
|
||||
// All OK.. We can proceed. Type B: source is a file, target is a folder and exists.
|
||||
newTargetURL := client.NewURL(targetURL)
|
||||
newTargetURL.Path = filepath.Join(newTargetURL.Path,
|
||||
strings.TrimPrefix(sourceContent.Content.URL.Path, url2Dir(sourceURL)))
|
||||
|
||||
copyURLsCh <- prepareCopyURLsTypeA(sourceContent.Content.URL.String(), newTargetURL.String())
|
||||
newSourceURL := sourceContent.Content.URL.String()
|
||||
newSourceSuffix := strings.TrimPrefix(newSourceURL, sourceURL)
|
||||
newTargetURL := urlJoinPath(targetURL, newSourceSuffix)
|
||||
copyURLsCh <- prepareCopyURLsTypeA(sourceContent.Content.URL.String(), newTargetURL)
|
||||
}
|
||||
}(sourceURL, targetURL, copyURLsCh)
|
||||
return copyURLsCh
|
||||
|
||||
@@ -29,20 +29,6 @@ const (
|
||||
recursiveSeparator = "..."
|
||||
)
|
||||
|
||||
// just like filepath.Dir but always has a trailing url.Seperator
|
||||
func url2Dir(urlStr string) string {
|
||||
url := client.NewURL(urlStr)
|
||||
if strings.HasSuffix(urlStr, string(url.Separator)) {
|
||||
return urlStr
|
||||
}
|
||||
lastIndex := strings.LastIndex(urlStr, string(url.Separator))
|
||||
dirname := urlStr[:lastIndex+1]
|
||||
if dirname == "" {
|
||||
return "."
|
||||
}
|
||||
return dirname
|
||||
}
|
||||
|
||||
// urlJoinPath Join a path to existing URL.
|
||||
func urlJoinPath(url1, url2 string) string {
|
||||
u1 := client.NewURL(url1)
|
||||
|
||||
Reference in New Issue
Block a user