Browse Source

Merge pull request #1053 from AudriusButkevicius/symdis

Add option to disable symlinks (fixes #1017)
Jakob Borg 11 years ago
parent
commit
8a34158fa4

+ 5 - 0
cmd/syncthing/main.go

@@ -45,6 +45,7 @@ import (
 	"github.com/syncthing/syncthing/internal/model"
 	"github.com/syncthing/syncthing/internal/model"
 	"github.com/syncthing/syncthing/internal/osutil"
 	"github.com/syncthing/syncthing/internal/osutil"
 	"github.com/syncthing/syncthing/internal/protocol"
 	"github.com/syncthing/syncthing/internal/protocol"
+	"github.com/syncthing/syncthing/internal/symlinks"
 	"github.com/syncthing/syncthing/internal/upgrade"
 	"github.com/syncthing/syncthing/internal/upgrade"
 	"github.com/syncthing/syncthing/internal/upnp"
 	"github.com/syncthing/syncthing/internal/upnp"
 	"github.com/syndtr/goleveldb/leveldb"
 	"github.com/syndtr/goleveldb/leveldb"
@@ -457,6 +458,10 @@ func syncthingMain() {
 
 
 	opts := cfg.Options()
 	opts := cfg.Options()
 
 
+	if opts.DisableSymlinks {
+		symlinks.Supported = false
+	}
+
 	if opts.MaxSendKbps > 0 {
 	if opts.MaxSendKbps > 0 {
 		writeRateLimit = ratelimit.NewBucketWithRate(float64(1000*opts.MaxSendKbps), int64(5*1000*opts.MaxSendKbps))
 		writeRateLimit = ratelimit.NewBucketWithRate(float64(1000*opts.MaxSendKbps), int64(5*1000*opts.MaxSendKbps))
 	}
 	}

+ 1 - 0
internal/config/config.go

@@ -179,6 +179,7 @@ type OptionsConfiguration struct {
 	KeepTemporariesH        int      `xml:"keepTemporariesH" default:"24"`     // 0 for off
 	KeepTemporariesH        int      `xml:"keepTemporariesH" default:"24"`     // 0 for off
 	CacheIgnoredFiles       bool     `xml:"cacheIgnoredFiles" default:"true"`
 	CacheIgnoredFiles       bool     `xml:"cacheIgnoredFiles" default:"true"`
 	ProgressUpdateIntervalS int      `xml:"progressUpdateIntervalS" default:"5"`
 	ProgressUpdateIntervalS int      `xml:"progressUpdateIntervalS" default:"5"`
+	DisableSymlinks         bool     `xml:"disableSymlinks" default:"false"`
 
 
 	Deprecated_RescanIntervalS int    `xml:"rescanIntervalS,omitempty" json:"-"`
 	Deprecated_RescanIntervalS int    `xml:"rescanIntervalS,omitempty" json:"-"`
 	Deprecated_UREnabled       bool   `xml:"urEnabled,omitempty" json:"-"`
 	Deprecated_UREnabled       bool   `xml:"urEnabled,omitempty" json:"-"`

+ 2 - 0
internal/config/config_test.go

@@ -53,6 +53,7 @@ func TestDefaultValues(t *testing.T) {
 		KeepTemporariesH:        24,
 		KeepTemporariesH:        24,
 		CacheIgnoredFiles:       true,
 		CacheIgnoredFiles:       true,
 		ProgressUpdateIntervalS: 5,
 		ProgressUpdateIntervalS: 5,
+		DisableSymlinks:         false,
 	}
 	}
 
 
 	cfg := New(device1)
 	cfg := New(device1)
@@ -155,6 +156,7 @@ func TestOverriddenValues(t *testing.T) {
 		KeepTemporariesH:        48,
 		KeepTemporariesH:        48,
 		CacheIgnoredFiles:       false,
 		CacheIgnoredFiles:       false,
 		ProgressUpdateIntervalS: 10,
 		ProgressUpdateIntervalS: 10,
+		DisableSymlinks:         true,
 	}
 	}
 
 
 	cfg, err := Load("testdata/overridenvalues.xml", device1)
 	cfg, err := Load("testdata/overridenvalues.xml", device1)

+ 1 - 0
internal/config/testdata/overridenvalues.xml

@@ -20,5 +20,6 @@
         <keepTemporariesH>48</keepTemporariesH>
         <keepTemporariesH>48</keepTemporariesH>
         <cacheIgnoredFiles>false</cacheIgnoredFiles>
         <cacheIgnoredFiles>false</cacheIgnoredFiles>
         <progressUpdateIntervalS>10</progressUpdateIntervalS>
         <progressUpdateIntervalS>10</progressUpdateIntervalS>
+        <disableSymlinks>true</disableSymlinks>
     </options>
     </options>
 </configuration>
 </configuration>

+ 1 - 1
internal/model/model.go

@@ -1360,7 +1360,7 @@ func (m *Model) leveldbPanicWorkaround() {
 func symlinkInvalid(isLink bool) bool {
 func symlinkInvalid(isLink bool) bool {
 	if !symlinks.Supported && isLink {
 	if !symlinks.Supported && isLink {
 		SymlinkWarning.Do(func() {
 		SymlinkWarning.Do(func() {
-			l.Warnln("Symlinks are unsupported as they require Administrator priviledges. This might cause your folder to appear out of sync.")
+			l.Warnln("Symlinks are disabled, unsupported or require Administrator priviledges. This might cause your folder to appear out of sync.")
 		})
 		})
 		return true
 		return true
 	}
 	}