cmd, lib: Fix ineffectual assignments (ineffasign) and comment spelling

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3405
This commit is contained in:
Jakob Borg
2016-07-15 14:23:20 +00:00
parent e3ccc45d19
commit 3176629410
11 changed files with 25 additions and 19 deletions

View File

@@ -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 {

View File

@@ -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()

View File

@@ -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,

View File

@@ -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")
}

View File

@@ -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))

View File

@@ -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

View File

@@ -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,