mirror of
https://github.com/syncthing/syncthing.git
synced 2026-08-07 05:43:24 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58523060f0 | ||
|
|
07d53be9fc | ||
|
|
d4b0235a8b | ||
|
|
34aa41e17b | ||
|
|
36f6a9347c |
No files matched your search
@@ -201,7 +201,7 @@ func reportData(cfg *config.Wrapper, m *model.Model) map[string]interface{} {
|
|||||||
defaultRelayServers, otherRelayServers := 0, 0
|
defaultRelayServers, otherRelayServers := 0, 0
|
||||||
for _, addr := range cfg.Options().RelayServers {
|
for _, addr := range cfg.Options().RelayServers {
|
||||||
switch addr {
|
switch addr {
|
||||||
case "dynamic+https://relays.syncthing.net":
|
case "dynamic+https://relays.syncthing.net/endpoint":
|
||||||
defaultRelayServers++
|
defaultRelayServers++
|
||||||
default:
|
default:
|
||||||
otherRelayServers++
|
otherRelayServers++
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) {
|
|||||||
cfg.Options.ListenAddress = uniqueStrings(cfg.Options.ListenAddress)
|
cfg.Options.ListenAddress = uniqueStrings(cfg.Options.ListenAddress)
|
||||||
cfg.Options.GlobalAnnServers = uniqueStrings(cfg.Options.GlobalAnnServers)
|
cfg.Options.GlobalAnnServers = uniqueStrings(cfg.Options.GlobalAnnServers)
|
||||||
|
|
||||||
if cfg.Version < OldestHandledVersion {
|
if cfg.Version > 0 && cfg.Version < OldestHandledVersion {
|
||||||
l.Warnf("Configuration version %d is deprecated. Attempting best effort conversion, but please verify manually.", cfg.Version)
|
l.Warnf("Configuration version %d is deprecated. Attempting best effort conversion, but please verify manually.", cfg.Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,13 @@ func TestDeviceConfig(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The cachedPath will have been resolved to an absolute path,
|
||||||
|
// depending on where the tests are running. Zero it out so we don't
|
||||||
|
// fail based on that.
|
||||||
|
for i := range cfg.Folders {
|
||||||
|
cfg.Folders[i].cachedPath = ""
|
||||||
|
}
|
||||||
|
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
expectedFolders[0].RawPath += string(filepath.Separator)
|
expectedFolders[0].RawPath += string(filepath.Separator)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ type FolderConfiguration struct {
|
|||||||
PullerPauseS int `xml:"pullerPauseS" json:"pullerPauseS"`
|
PullerPauseS int `xml:"pullerPauseS" json:"pullerPauseS"`
|
||||||
MaxConflicts int `xml:"maxConflicts" json:"maxConflicts"`
|
MaxConflicts int `xml:"maxConflicts" json:"maxConflicts"`
|
||||||
|
|
||||||
Invalid string `xml:"-" json:"invalid"` // Set at runtime when there is an error, not saved
|
Invalid string `xml:"-" json:"invalid"` // Set at runtime when there is an error, not saved
|
||||||
|
cachedPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
type FolderDeviceConfiguration struct {
|
type FolderDeviceConfiguration struct {
|
||||||
@@ -55,28 +56,11 @@ func (f FolderConfiguration) Path() string {
|
|||||||
// This is intentionally not a pointer method, because things like
|
// This is intentionally not a pointer method, because things like
|
||||||
// cfg.Folders["default"].Path() should be valid.
|
// cfg.Folders["default"].Path() should be valid.
|
||||||
|
|
||||||
// Attempt tilde expansion; leave unchanged in case of error
|
if f.cachedPath == "" {
|
||||||
if path, err := osutil.ExpandTilde(f.RawPath); err == nil {
|
l.Infoln("bug: uncached path call (should only happen in tests)")
|
||||||
f.RawPath = path
|
return f.cleanedPath()
|
||||||
}
|
}
|
||||||
|
return f.cachedPath
|
||||||
// Attempt absolutification; leave unchanged in case of error
|
|
||||||
if !filepath.IsAbs(f.RawPath) {
|
|
||||||
// Abs() looks like a fairly expensive syscall on Windows, while
|
|
||||||
// IsAbs() is a whole bunch of string mangling. I think IsAbs() may be
|
|
||||||
// somewhat faster in the general case, hence the outer if...
|
|
||||||
if path, err := filepath.Abs(f.RawPath); err == nil {
|
|
||||||
f.RawPath = path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt to enable long filename support on Windows. We may still not
|
|
||||||
// have an absolute path here if the previous steps failed.
|
|
||||||
if runtime.GOOS == "windows" && filepath.IsAbs(f.RawPath) && !strings.HasPrefix(f.RawPath, `\\`) {
|
|
||||||
return `\\?\` + f.RawPath
|
|
||||||
}
|
|
||||||
|
|
||||||
return f.RawPath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FolderConfiguration) CreateMarker() error {
|
func (f *FolderConfiguration) CreateMarker() error {
|
||||||
@@ -129,6 +113,8 @@ func (f *FolderConfiguration) prepare() {
|
|||||||
f.RawPath = f.RawPath + string(filepath.Separator)
|
f.RawPath = f.RawPath + string(filepath.Separator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f.cachedPath = f.cleanedPath()
|
||||||
|
|
||||||
if f.ID == "" {
|
if f.ID == "" {
|
||||||
f.ID = "default"
|
f.ID = "default"
|
||||||
}
|
}
|
||||||
@@ -140,6 +126,33 @@ func (f *FolderConfiguration) prepare() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *FolderConfiguration) cleanedPath() string {
|
||||||
|
cleaned := f.RawPath
|
||||||
|
|
||||||
|
// Attempt tilde expansion; leave unchanged in case of error
|
||||||
|
if path, err := osutil.ExpandTilde(cleaned); err == nil {
|
||||||
|
cleaned = path
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt absolutification; leave unchanged in case of error
|
||||||
|
if !filepath.IsAbs(cleaned) {
|
||||||
|
// Abs() looks like a fairly expensive syscall on Windows, while
|
||||||
|
// IsAbs() is a whole bunch of string mangling. I think IsAbs() may be
|
||||||
|
// somewhat faster in the general case, hence the outer if...
|
||||||
|
if path, err := filepath.Abs(cleaned); err == nil {
|
||||||
|
cleaned = path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt to enable long filename support on Windows. We may still not
|
||||||
|
// have an absolute path here if the previous steps failed.
|
||||||
|
if runtime.GOOS == "windows" && filepath.IsAbs(cleaned) && !strings.HasPrefix(f.RawPath, `\\`) {
|
||||||
|
return `\\?\` + cleaned
|
||||||
|
}
|
||||||
|
|
||||||
|
return cleaned
|
||||||
|
}
|
||||||
|
|
||||||
type FolderDeviceConfigurationList []FolderDeviceConfiguration
|
type FolderDeviceConfigurationList []FolderDeviceConfiguration
|
||||||
|
|
||||||
func (l FolderDeviceConfigurationList) Less(a, b int) bool {
|
func (l FolderDeviceConfigurationList) Less(a, b int) bool {
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import (
|
|||||||
|
|
||||||
"github.com/syncthing/syncthing/lib/db"
|
"github.com/syncthing/syncthing/lib/db"
|
||||||
"github.com/syncthing/syncthing/lib/protocol"
|
"github.com/syncthing/syncthing/lib/protocol"
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
|
||||||
"github.com/syndtr/goleveldb/leveldb/opt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var files, oneFile, firstHalf, secondHalf []protocol.FileInfo
|
var files, oneFile, firstHalf, secondHalf []protocol.FileInfo
|
||||||
@@ -44,16 +42,16 @@ func init() {
|
|||||||
fs.Replace(protocol.LocalDeviceID, firstHalf)
|
fs.Replace(protocol.LocalDeviceID, firstHalf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func tempDB() (*leveldb.DB, string) {
|
func tempDB() (*db.Instance, string) {
|
||||||
dir, err := ioutil.TempDir("", "syncthing")
|
dir, err := ioutil.TempDir("", "syncthing")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
db, err := leveldb.OpenFile(filepath.Join(dir, "db"), &opt.Options{OpenFilesCacheCapacity: 100})
|
dbi, err := db.Open(filepath.Join(dir, "db"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return db, dir
|
return dbi, dir
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkReplaceAll(b *testing.B) {
|
func BenchmarkReplaceAll(b *testing.B) {
|
||||||
|
|||||||
@@ -109,6 +109,12 @@ func (m *CachingMux) Lookup(deviceID protocol.DeviceID) (direct []string, relays
|
|||||||
when: time.Now(),
|
when: time.Now(),
|
||||||
found: len(td)+len(tr) > 0,
|
found: len(td)+len(tr) > 0,
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
// Lookup returned error, add a negative cache entry.
|
||||||
|
m.caches[i].Set(deviceID, CacheEntry{
|
||||||
|
when: time.Now(),
|
||||||
|
found: false,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.mut.Unlock()
|
m.mut.Unlock()
|
||||||
|
|||||||
Reference in new issue
Block a user