cp: Fix a crash in cp - fixes #1336

This commit is contained in:
Harshavardhana
2015-11-16 10:09:47 -08:00
parent c7ab507354
commit b10f709c09
+5 -2
View File
@@ -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)
}