all: A few more interesting linter fixes (#5502)
A couple of minor bugs and simplifications
This commit is contained in:
@@ -115,7 +115,7 @@ type Model struct {
|
||||
type folderFactory func(*Model, config.FolderConfiguration, versioner.Versioner, fs.Filesystem) service
|
||||
|
||||
var (
|
||||
folderFactories = make(map[config.FolderType]folderFactory, 0)
|
||||
folderFactories = make(map[config.FolderType]folderFactory)
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -489,12 +489,8 @@ func (m *Model) UsageReportingStats(version int, preview bool) map[string]interf
|
||||
}
|
||||
|
||||
// Noops, remove
|
||||
if strings.HasSuffix(line, "**") {
|
||||
line = line[:len(line)-2]
|
||||
}
|
||||
if strings.HasPrefix(line, "**/") {
|
||||
line = line[3:]
|
||||
}
|
||||
line = strings.TrimSuffix(line, "**")
|
||||
line = strings.TrimPrefix(line, "**/")
|
||||
|
||||
if strings.HasPrefix(line, "/") {
|
||||
ignoreStats["rooted"] += 1
|
||||
@@ -508,7 +504,7 @@ func (m *Model) UsageReportingStats(version int, preview bool) map[string]interf
|
||||
if strings.Contains(line, "**") {
|
||||
ignoreStats["doubleStars"] += 1
|
||||
// Remove not to trip up star checks.
|
||||
strings.Replace(line, "**", "", -1)
|
||||
line = strings.Replace(line, "**", "", -1)
|
||||
}
|
||||
|
||||
if strings.Contains(line, "*") {
|
||||
@@ -2392,6 +2388,11 @@ func (m *Model) GetFolderVersions(folder string) (map[string][]versioner.FileVer
|
||||
return nil
|
||||
}
|
||||
|
||||
// Skip walking if we cannot walk...
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Ignore symlinks
|
||||
if f.IsSymlink() {
|
||||
return fs.SkipDir
|
||||
|
||||
@@ -2572,7 +2572,7 @@ func TestIssue2782(t *testing.T) {
|
||||
}
|
||||
|
||||
m.fmut.Lock()
|
||||
runner, _ := m.folderRunners["default"]
|
||||
runner := m.folderRunners["default"]
|
||||
m.fmut.Unlock()
|
||||
if err := runner.CheckHealth(); err != nil {
|
||||
t.Error("health check error:", err)
|
||||
|
||||
@@ -167,13 +167,14 @@ func (t *ProgressEmitter) sendDownloadProgressMessages() {
|
||||
// If we fail to find that folder, we tell the state to forget about it
|
||||
// and return us a list of updates which would clean up the state
|
||||
// on the remote end.
|
||||
updates := state.cleanup(folder)
|
||||
if len(updates) > 0 {
|
||||
// XXX: Don't send this now, as the only way we've unshared a folder
|
||||
// is by breaking the connection and reconnecting, hence sending
|
||||
// forget messages for some random folder currently makes no sense.
|
||||
// deviceConns[id].DownloadProgress(folder, updates, 0, nil)
|
||||
}
|
||||
state.cleanup(folder)
|
||||
// updates := state.cleanup(folder)
|
||||
// if len(updates) > 0 {
|
||||
// XXX: Don't send this now, as the only way we've unshared a folder
|
||||
// is by breaking the connection and reconnecting, hence sending
|
||||
// forget messages for some random folder currently makes no sense.
|
||||
// deviceConns[id].DownloadProgress(folder, updates, 0, nil)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
|
||||
v2 := (protocol.Vector{}).Update(1)
|
||||
|
||||
// Requires more than 10 blocks to work.
|
||||
blocks := make([]protocol.BlockInfo, 11, 11)
|
||||
blocks := make([]protocol.BlockInfo, 11)
|
||||
|
||||
state1 := &sharedPullerState{
|
||||
folder: "folder",
|
||||
|
||||
@@ -471,7 +471,6 @@ func TestIssue4841(t *testing.T) {
|
||||
t.Fatalf(`Sent index with file %v, should be "foo"`, fs[0].Name)
|
||||
}
|
||||
received <- fs[0]
|
||||
return
|
||||
}
|
||||
fc.mut.Unlock()
|
||||
|
||||
@@ -521,7 +520,6 @@ func TestRescanIfHaveInvalidContent(t *testing.T) {
|
||||
t.Fatalf(`Sent index with file %v, should be "foo"`, fs[0].Name)
|
||||
}
|
||||
received <- fs[0]
|
||||
return
|
||||
}
|
||||
fc.mut.Unlock()
|
||||
|
||||
@@ -551,7 +549,7 @@ func TestRescanIfHaveInvalidContent(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
res, err = m.Request(device2, "default", "foo", int32(len(payload)), 0, f.Blocks[0].Hash, f.Blocks[0].WeakHash, false)
|
||||
_, err = m.Request(device2, "default", "foo", int32(len(payload)), 0, f.Blocks[0].Hash, f.Blocks[0].WeakHash, false)
|
||||
if err == nil {
|
||||
t.Fatalf("expected failure")
|
||||
}
|
||||
@@ -586,7 +584,6 @@ func TestParentDeletion(t *testing.T) {
|
||||
fc.mut.Lock()
|
||||
fc.indexFn = func(folder string, fs []protocol.FileInfo) {
|
||||
received <- fs
|
||||
return
|
||||
}
|
||||
fc.mut.Unlock()
|
||||
fc.sendIndexUpdate()
|
||||
|
||||
Reference in New Issue
Block a user