mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 10:28:49 -07:00
Use same order of parameters as os.Symlink
This commit is contained in:
parent
1ff9bb8fdc
commit
2abe792f36
@ -817,7 +817,7 @@ func (p *Puller) performFinish(state *sharedPullerState) {
|
||||
// Remove the file, and replace it with a symlink.
|
||||
err = osutil.InWritableDir(func(path string) error {
|
||||
os.Remove(path)
|
||||
return symlinks.Create(path, string(content), state.file.Flags)
|
||||
return symlinks.Create(string(content), path, state.file.Flags)
|
||||
}, state.realName)
|
||||
if err != nil {
|
||||
l.Warnln("puller: final: creating symlink:", err)
|
||||
|
@ -48,7 +48,7 @@ func IsSymlink(path string) (bool, error) {
|
||||
return lstat.Mode()&os.ModeSymlink != 0, nil
|
||||
}
|
||||
|
||||
func Create(source, target string, flags uint32) error {
|
||||
func Create(target, source string, flags uint32) error {
|
||||
return os.Symlink(osutil.NativeFilename(target), source)
|
||||
}
|
||||
|
||||
@ -77,6 +77,6 @@ func ChangeType(path string, flags uint32) error {
|
||||
// It should be a symlink as well hence no need to change permissions
|
||||
// on the file.
|
||||
os.Remove(path)
|
||||
return Create(path, target, flags)
|
||||
return Create(target, path, flags)
|
||||
}, path)
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func TestSymlinks(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fd.Close()
|
||||
err = symlinks.Create("s1/fileLink", "file", 0)
|
||||
err = symlinks.Create("file", "s1/fileLink", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -73,35 +73,35 @@ func TestSymlinks(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = symlinks.Create("s1/dirLink", "dir", 0)
|
||||
err = symlinks.Create("dir", "s1/dirLink", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// A link to something in the repo that does not exist
|
||||
|
||||
err = symlinks.Create("s1/noneLink", "does/not/exist", 0)
|
||||
err = symlinks.Create("does/not/exist", "s1/noneLink", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// A link we will replace with a file later
|
||||
|
||||
err = symlinks.Create("s1/repFileLink", "does/not/exist", 0)
|
||||
err = symlinks.Create("does/not/exist", "s1/repFileLink", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// A link we will replace with a directory later
|
||||
|
||||
err = symlinks.Create("s1/repDirLink", "does/not/exist", 0)
|
||||
err = symlinks.Create("does/not/exist", "s1/repDirLink", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// A link we will remove later
|
||||
|
||||
err = symlinks.Create("s1/removeLink", "does/not/exist", 0)
|
||||
err = symlinks.Create("does/not/exist", "s1/removeLink", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -184,7 +184,7 @@ func TestSymlinks(t *testing.T) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = symlinks.Create("s1/dirLink", "file", 0)
|
||||
err = symlinks.Create("file", "s1/dirLink", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -220,7 +220,7 @@ func TestSymlinks(t *testing.T) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = symlinks.Create("s1/fileToReplace", "somewhere/non/existent", 0)
|
||||
err = symlinks.Create("somewhere/non/existent", "s1/fileToReplace", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -231,7 +231,7 @@ func TestSymlinks(t *testing.T) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = symlinks.Create("s1/dirToReplace", "somewhere/non/existent", 0)
|
||||
err = symlinks.Create("somewhere/non/existent", "s1/dirToReplace", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user