cache: fix Windows separator issue for #1904 (#1930)

This commit is contained in:
remusb 2017-12-20 17:24:50 +02:00 committed by GitHub
parent 4ba58884b1
commit 0d4bff8239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

8
cache/directory.go vendored
View File

@ -5,9 +5,7 @@ package cache
import (
"time"
"os"
"path"
"strings"
"github.com/ncw/rclone/fs"
)
@ -97,8 +95,10 @@ func (d *Directory) String() string {
func (d *Directory) Remote() string {
p := cleanPath(path.Join(d.Dir, d.Name))
if d.CacheFs.Root() != "" {
p = strings.Replace(p, d.CacheFs.Root(), "", 1)
p = strings.TrimPrefix(p, string(os.PathSeparator))
p = p[len(d.CacheFs.Root()):] // trim out root
if len(p) > 0 { // remove first separator
p = p[1:]
}
}
return p

7
cache/object.go vendored
View File

@ -7,7 +7,6 @@ import (
"io"
"os"
"path"
"strings"
"sync"
"time"
@ -133,8 +132,10 @@ func (o *Object) String() string {
func (o *Object) Remote() string {
p := path.Join(o.Dir, o.Name)
if o.CacheFs.Root() != "" {
p = strings.Replace(p, o.CacheFs.Root(), "", 1)
p = strings.TrimPrefix(p, string(os.PathSeparator))
p = p[len(o.CacheFs.Root()):] // trim out root
if len(p) > 0 { // remove first separator
p = p[1:]
}
}
return p