mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:54:44 +01:00
netstorage,quatrix,seafile: fix Root to return correct directory when pointing to a file
This fixes the TestIntegration/FsMkdir/FsPutFiles/FsIsFile/FsRoot integration test.
This commit is contained in:
parent
5750795324
commit
339d3e8ee6
@ -15,6 +15,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -260,6 +261,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
|||||||
case fs.ErrorObjectNotFound:
|
case fs.ErrorObjectNotFound:
|
||||||
return f, nil
|
return f, nil
|
||||||
case fs.ErrorIsFile:
|
case fs.ErrorIsFile:
|
||||||
|
// Correct root if definitely pointing to a file
|
||||||
|
f.root = path.Dir(f.root)
|
||||||
|
if f.root == "." || f.root == "/" {
|
||||||
|
f.root = ""
|
||||||
|
}
|
||||||
// Fs points to the parent directory
|
// Fs points to the parent directory
|
||||||
return f, err
|
return f, err
|
||||||
default:
|
default:
|
||||||
|
@ -235,6 +235,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
|||||||
if fileID.IsFile() {
|
if fileID.IsFile() {
|
||||||
root, _ = dircache.SplitPath(root)
|
root, _ = dircache.SplitPath(root)
|
||||||
f.dirCache = dircache.New(root, rootID.FileID, f)
|
f.dirCache = dircache.New(root, rootID.FileID, f)
|
||||||
|
// Correct root if definitely pointing to a file
|
||||||
|
f.root = path.Dir(f.root)
|
||||||
|
if f.root == "." || f.root == "/" {
|
||||||
|
f.root = ""
|
||||||
|
}
|
||||||
|
|
||||||
return f, fs.ErrorIsFile
|
return f, fs.ErrorIsFile
|
||||||
}
|
}
|
||||||
|
@ -301,6 +301,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
|||||||
}
|
}
|
||||||
return f, err
|
return f, err
|
||||||
}
|
}
|
||||||
|
// Correct root if definitely pointing to a file
|
||||||
|
f.root = path.Dir(f.root)
|
||||||
|
if f.root == "." || f.root == "/" {
|
||||||
|
f.root = ""
|
||||||
|
}
|
||||||
// return an error with an fs which points to the parent
|
// return an error with an fs which points to the parent
|
||||||
return f, fs.ErrorIsFile
|
return f, fs.ErrorIsFile
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user