diff --git a/cmd/stdiscosrv/psql.go b/cmd/stdiscosrv/psql.go index d4af7fe6..c90396f4 100644 --- a/cmd/stdiscosrv/psql.go +++ b/cmd/stdiscosrv/psql.go @@ -28,7 +28,7 @@ func postgresSetup(db *sql.DB) error { } row := db.QueryRow(`SELECT 'DevicesDeviceIDIndex'::regclass`) - if err := row.Scan(nil); err != nil { + if err = row.Scan(nil); err != nil { _, err = db.Exec(`CREATE INDEX DevicesDeviceIDIndex ON Devices (DeviceID)`) } if err != nil { @@ -36,7 +36,7 @@ func postgresSetup(db *sql.DB) error { } row = db.QueryRow(`SELECT 'DevicesSeenIndex'::regclass`) - if err := row.Scan(nil); err != nil { + if err = row.Scan(nil); err != nil { _, err = db.Exec(`CREATE INDEX DevicesSeenIndex ON Devices (Seen)`) } if err != nil { @@ -53,7 +53,7 @@ func postgresSetup(db *sql.DB) error { } row = db.QueryRow(`SELECT 'AddressesDeviceIDSeenIndex'::regclass`) - if err := row.Scan(nil); err != nil { + if err = row.Scan(nil); err != nil { _, err = db.Exec(`CREATE INDEX AddressesDeviceIDSeenIndex ON Addresses (DeviceID, Seen)`) } if err != nil { @@ -61,7 +61,7 @@ func postgresSetup(db *sql.DB) error { } row = db.QueryRow(`SELECT 'AddressesDeviceIDAddressIndex'::regclass`) - if err := row.Scan(nil); err != nil { + if err = row.Scan(nil); err != nil { _, err = db.Exec(`CREATE INDEX AddressesDeviceIDAddressIndex ON Addresses (DeviceID, Address)`) } if err != nil { diff --git a/cmd/strelaypoolsrv/main.go b/cmd/strelaypoolsrv/main.go index e51714b5..1c9e0e91 100644 --- a/cmd/strelaypoolsrv/main.go +++ b/cmd/strelaypoolsrv/main.go @@ -130,7 +130,8 @@ func main() { log.Println("Starting TLS listener on", listen) } certFile, keyFile := filepath.Join(dir, "http-cert.pem"), filepath.Join(dir, "http-key.pem") - cert, err := tls.LoadX509KeyPair(certFile, keyFile) + var cert tls.Certificate + cert, err = tls.LoadX509KeyPair(certFile, keyFile) if err != nil { log.Fatalln("Failed to load HTTP X509 key pair:", err) } diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index bc94d429..e4f8e022 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -539,8 +539,9 @@ func syncthingMain(runtimeOptions RuntimeOptions) { errors := logger.NewRecorder(l, logger.LevelWarn, maxSystemErrors, 0) systemLog := logger.NewRecorder(l, logger.LevelDebug, maxSystemLog, initialSystemLog) - // Event subscription for the API; must start early to catch the early events. The LocalChangeDetected - // event might overwhelm the event reciever in some situations so we will not subscribe to it here. + // Event subscription for the API; must start early to catch the early + // events. The LocalChangeDetected event might overwhelm the event + // receiver in some situations so we will not subscribe to it here. apiSub := events.NewBufferedSubscription(events.Default.Subscribe(events.AllEvents&^events.LocalChangeDetected), 1000) if len(os.Getenv("GOMAXPROCS")) == 0 { diff --git a/lib/config/config.go b/lib/config/config.go index 97e72c93..281de7c2 100644 --- a/lib/config/config.go +++ b/lib/config/config.go @@ -105,7 +105,9 @@ func ReadJSON(r io.Reader, myID protocol.DeviceID) (Configuration, error) { return Configuration{}, err } - err = json.Unmarshal(bs, &cfg) + if err := json.Unmarshal(bs, &cfg); err != nil { + return Configuration{}, err + } cfg.OriginalVersion = cfg.Version if err := cfg.prepare(myID); err != nil { diff --git a/lib/config/config_test.go b/lib/config/config_test.go index a4802ca4..e3384d3c 100644 --- a/lib/config/config_test.go +++ b/lib/config/config_test.go @@ -549,6 +549,9 @@ func TestPullOrder(t *testing.T) { t.Logf("%s", buf.Bytes()) cfg, err = ReadXML(buf, device1) + if err != nil { + t.Fatal(err) + } wrapper = Wrap("testdata/pullorder.xml", cfg) folders = wrapper.Folders() diff --git a/lib/model/model.go b/lib/model/model.go index 20b4f12c..a647cef0 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -1293,7 +1293,7 @@ func (m *Model) localChangeDetected(folder, path string, files []protocol.FileIn objType := "file" action := "modified" - // If our local vector is verison 1 AND it is the only version + // If our local vector is version 1 AND it is the only version // vector so far seen for this file then it is a new file. Else if // it is > 1 it's not new, and if it is 1 but another shortId // version vector exists then it is new for us but created elsewhere @@ -1311,11 +1311,8 @@ func (m *Model) localChangeDetected(folder, path string, files []protocol.FileIn action = "deleted" } - // If the file is a level or more deep then the forward slash seperator is embedded - // in the filename and makes the path look wierd on windows, so lets fix it - filename := filepath.FromSlash(file.Name) - // And append it to the filepath - path := filepath.Join(path, filename) + // The full file path, adjusted to the local path separator character. + path := filepath.Join(path, filepath.FromSlash(file.Name)) events.Default.Log(events.LocalChangeDetected, map[string]string{ "folder": folder, diff --git a/lib/model/model_test.go b/lib/model/model_test.go index 5ecccdb6..ff95c767 100644 --- a/lib/model/model_test.go +++ b/lib/model/model_test.go @@ -563,7 +563,7 @@ func TestIgnores(t *testing.T) { // Invalid path, marker should be missing, hence returns an error. m.AddFolder(config.FolderConfiguration{ID: "fresh", RawPath: "XXX"}) - ignores, _, err = m.GetIgnores("fresh") + _, _, err = m.GetIgnores("fresh") if err == nil { t.Error("No error") } diff --git a/lib/model/sharedpullerstate_test.go b/lib/model/sharedpullerstate_test.go index 315c3d41..ffde2b7b 100644 --- a/lib/model/sharedpullerstate_test.go +++ b/lib/model/sharedpullerstate_test.go @@ -29,6 +29,9 @@ func TestSourceFileOK(t *testing.T) { bs := make([]byte, 6) n, err := fd.Read(bs) + if err != nil { + t.Fatal(err) + } if n != len(bs) { t.Fatalf("Wrong read length %d != %d", n, len(bs)) diff --git a/lib/scanner/walk.go b/lib/scanner/walk.go index 5f361401..2287d0ad 100644 --- a/lib/scanner/walk.go +++ b/lib/scanner/walk.go @@ -470,8 +470,6 @@ func (w *walker) normalizePath(absPath, relPath string) (normPath string, skip b l.Infof(`File "%s" has UTF8 encoding conflict with another file; ignoring.`, relPath) return "", true } - - relPath = normPath } return normPath, false diff --git a/lib/stats/folder.go b/lib/stats/folder.go index 1ab97500..0644d45d 100644 --- a/lib/stats/folder.go +++ b/lib/stats/folder.go @@ -45,7 +45,7 @@ func (s *FolderStatisticsReference) GetLastFile() LastFile { if !ok { return LastFile{} } - deleted, ok := s.ns.Bool("lastFileDeleted") + deleted, _ := s.ns.Bool("lastFileDeleted") return LastFile{ At: at, Filename: file, diff --git a/test/transfer-bench_test.go b/test/transfer-bench_test.go index fb3607a0..3b9ddeb8 100644 --- a/test/transfer-bench_test.go +++ b/test/transfer-bench_test.go @@ -50,7 +50,8 @@ func benchmarkTransfer(t *testing.T, files, sizeExp int) { log.Println("Generating files...") if files == 1 { // Special case. Generate one file with the specified size exactly. - fd, err := os.Open("../LICENSE") + var fd *os.File + fd, err = os.Open("../LICENSE") if err != nil { t.Fatal(err) }