1
0
mirror of https://github.com/rclone/rclone.git synced 2025-01-08 12:34:53 +02:00

union: fix slash behaviour on Windows

This commit is contained in:
Nick Craig-Wood 2020-03-10 15:59:42 +00:00
parent 7da83346bf
commit 98ad80bee3
4 changed files with 10 additions and 11 deletions

View File

@ -2,7 +2,7 @@ package policy
import (
"context"
"path/filepath"
"path"
"sync"
"github.com/rclone/rclone/backend/union/upstream"
@ -21,7 +21,7 @@ type EpAll struct {
EpFF
}
func (p *EpAll) epall(ctx context.Context, upstreams []*upstream.Fs, path string) ([]*upstream.Fs, error) {
func (p *EpAll) epall(ctx context.Context, upstreams []*upstream.Fs, filePath string) ([]*upstream.Fs, error) {
var wg sync.WaitGroup
ufs := make([]*upstream.Fs, len(upstreams))
for i, u := range upstreams {
@ -29,7 +29,7 @@ func (p *EpAll) epall(ctx context.Context, upstreams []*upstream.Fs, path string
i, u := i, u // Closure
go func() {
rfs := u.RootFs
remote := filepath.Join(u.RootPath, path)
remote := path.Join(u.RootPath, filePath)
if findEntry(ctx, rfs, remote) != nil {
ufs[i] = u
}

View File

@ -2,7 +2,7 @@ package policy
import (
"context"
"path/filepath"
"path"
"github.com/rclone/rclone/backend/union/upstream"
"github.com/rclone/rclone/fs"
@ -16,13 +16,13 @@ func init() {
// Given the order of the candidates, act on the first one found where the relative path exists.
type EpFF struct{}
func (p *EpFF) epff(ctx context.Context, upstreams []*upstream.Fs, path string) (*upstream.Fs, error) {
func (p *EpFF) epff(ctx context.Context, upstreams []*upstream.Fs, filePath string) (*upstream.Fs, error) {
ch := make(chan *upstream.Fs)
for _, u := range upstreams {
u := u // Closure
go func() {
rfs := u.RootFs
remote := filepath.Join(u.RootPath, path)
remote := path.Join(u.RootPath, filePath)
if findEntry(ctx, rfs, remote) == nil {
u = nil
}

View File

@ -2,7 +2,7 @@ package policy
import (
"context"
"path/filepath"
"path"
"sync"
"time"
@ -20,7 +20,7 @@ type Newest struct {
EpAll
}
func (p *Newest) newest(ctx context.Context, upstreams []*upstream.Fs, path string) (*upstream.Fs, error) {
func (p *Newest) newest(ctx context.Context, upstreams []*upstream.Fs, filePath string) (*upstream.Fs, error) {
var wg sync.WaitGroup
ufs := make([]*upstream.Fs, len(upstreams))
mtimes := make([]time.Time, len(upstreams))
@ -30,7 +30,7 @@ func (p *Newest) newest(ctx context.Context, upstreams []*upstream.Fs, path stri
go func() {
defer wg.Done()
rfs := u.RootFs
remote := filepath.Join(u.RootPath, path)
remote := path.Join(u.RootPath, filePath)
if e := findEntry(ctx, rfs, remote); e != nil {
ufs[i] = u
mtimes[i] = e.ModTime(ctx)

View File

@ -4,7 +4,6 @@ import (
"context"
"math/rand"
"path"
"path/filepath"
"strings"
"time"
@ -95,7 +94,7 @@ func parentDir(absPath string) string {
}
func clean(absPath string) string {
cleanPath := path.Clean(filepath.ToSlash(absPath))
cleanPath := path.Clean(absPath)
if cleanPath == "." {
cleanPath = ""
}