mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
lib/fs: Basic with empty root shouldn't point at / (#6483)
This commit is contained in:
parent
9c67d57c28
commit
123941cf62
@ -30,6 +30,10 @@ type BasicFilesystem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newBasicFilesystem(root string) *BasicFilesystem {
|
func newBasicFilesystem(root string) *BasicFilesystem {
|
||||||
|
if root == "" {
|
||||||
|
root = "." // Otherwise "" becomes "/" below
|
||||||
|
}
|
||||||
|
|
||||||
// The reason it's done like this:
|
// The reason it's done like this:
|
||||||
// C: -> C:\ -> C:\ (issue that this is trying to fix)
|
// C: -> C:\ -> C:\ (issue that this is trying to fix)
|
||||||
// C:\somedir -> C:\somedir\ -> C:\somedir
|
// C:\somedir -> C:\somedir\ -> C:\somedir
|
||||||
|
@ -514,6 +514,10 @@ func TestNewBasicFilesystem(t *testing.T) {
|
|||||||
t.Skip("non-windows root paths")
|
t.Skip("non-windows root paths")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentDir, err := filepath.Abs(".")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input string
|
input string
|
||||||
expectedRoot string
|
expectedRoot string
|
||||||
@ -521,7 +525,8 @@ func TestNewBasicFilesystem(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{"/foo/bar/baz", "/foo/bar/baz", "/foo/bar/baz"},
|
{"/foo/bar/baz", "/foo/bar/baz", "/foo/bar/baz"},
|
||||||
{"/foo/bar/baz/", "/foo/bar/baz", "/foo/bar/baz"},
|
{"/foo/bar/baz/", "/foo/bar/baz", "/foo/bar/baz"},
|
||||||
{"", "/", "/"},
|
{"", currentDir, currentDir},
|
||||||
|
{".", currentDir, currentDir},
|
||||||
{"/", "/", "/"},
|
{"/", "/", "/"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user