all: Remove symlink support on Windows, SymlinksEnabled config

After this change,

- Symlinks on Windows are always unsupported. Sorry.

- Symlinks are always enabled on other platforms. They are just a small
  file like anything else. There is no need to special case them. If you
  don't want to sync some symlinks, ignore them.

- The protocol doesn't differentiate between different "types" of
  symlinks. If that distinction ever does become relevant the individual
  devices can figure it out by looking at the destination when they
  create the link.

It's backwards compatible in that all the old symlink types are still
understood to be symlinks, and the new SYMLINK type is equivalent to the
old SYMLINK_UNKNOWN which was always a valid way to do it.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3962
LGTM: AudriusButkevicius
This commit is contained in:
Jakob Borg
2017-02-07 08:34:24 +00:00
parent 9fda9642d3
commit c4ba580cbb
28 changed files with 227 additions and 707 deletions

View File

@@ -23,7 +23,6 @@ import (
"github.com/syncthing/syncthing/lib/ignore"
"github.com/syncthing/syncthing/lib/osutil"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/symlinks"
"golang.org/x/text/unicode/norm"
)
@@ -282,7 +281,7 @@ func TestIssue1507(t *testing.T) {
}
func TestWalkSymlink(t *testing.T) {
if !symlinks.Supported {
if runtime.GOOS == "windows" {
t.Skip("skipping unsupported symlink test")
return
}
@@ -293,7 +292,7 @@ func TestWalkSymlink(t *testing.T) {
defer os.RemoveAll("_symlinks")
os.Mkdir("_symlinks", 0755)
symlinks.Create("_symlinks/link", "destination", symlinks.TargetUnknown)
os.Symlink("destination", "_symlinks/link")
// Scan it
@@ -383,34 +382,6 @@ func (l testfileList) String() string {
return b.String()
}
func TestSymlinkTypeEqual(t *testing.T) {
testcases := []struct {
onDiskType symlinks.TargetType
fiType protocol.FileInfoType
equal bool
}{
// File is only equal to file
{symlinks.TargetFile, protocol.FileInfoTypeSymlinkFile, true},
{symlinks.TargetFile, protocol.FileInfoTypeSymlinkDirectory, false},
{symlinks.TargetFile, protocol.FileInfoTypeSymlinkUnknown, false},
// Directory is only equal to directory
{symlinks.TargetDirectory, protocol.FileInfoTypeSymlinkFile, false},
{symlinks.TargetDirectory, protocol.FileInfoTypeSymlinkDirectory, true},
{symlinks.TargetDirectory, protocol.FileInfoTypeSymlinkUnknown, false},
// Unknown is equal to anything
{symlinks.TargetUnknown, protocol.FileInfoTypeSymlinkFile, true},
{symlinks.TargetUnknown, protocol.FileInfoTypeSymlinkDirectory, true},
{symlinks.TargetUnknown, protocol.FileInfoTypeSymlinkUnknown, true},
}
for _, tc := range testcases {
res := SymlinkTypeEqual(tc.onDiskType, protocol.FileInfo{Type: tc.fiType})
if res != tc.equal {
t.Errorf("Incorrect result %v for %v, %v", res, tc.onDiskType, tc.fiType)
}
}
}
var initOnce sync.Once
const (