cp: Fix a crash in cp - fixes #1336
This commit is contained in:
@@ -292,8 +292,11 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan copyURLs {
|
||||
// All OK.. We can proceed. Type B: source is a file, target is a folder and exists.
|
||||
srcURL := sourceClient.GetURL()
|
||||
newSourceURL := sourceContent.Content.URL
|
||||
newSourceSuffix := strings.TrimPrefix(newSourceURL.Path,
|
||||
srcURL.Path[:strings.LastIndex(srcURL.Path, string(srcURL.Separator))])
|
||||
pathSeparatorIndex := strings.LastIndex(srcURL.Path, string(srcURL.Separator))
|
||||
newSourceSuffix := newSourceURL.Path
|
||||
if pathSeparatorIndex > 1 {
|
||||
newSourceSuffix = strings.TrimPrefix(newSourceURL.Path, srcURL.Path[:pathSeparatorIndex])
|
||||
}
|
||||
newTargetURL := urlJoinPath(targetURL, newSourceSuffix)
|
||||
copyURLsCh <- prepareCopyURLsTypeA(sourceContent.Content.URL.String(), newTargetURL)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user