Skip to content

Commit

Permalink
all: Cleanups enabled by Go 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Nov 10, 2019
1 parent 879f51b commit 1d99e52
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
17 changes: 7 additions & 10 deletions cmd/syncthing/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,14 @@ func monitorMain(runtimeOptions RuntimeOptions) {
// Successful exit indicates an intentional shutdown
return
} else if exiterr, ok := err.(*exec.ExitError); ok {
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
switch status.ExitStatus() {
case syncthing.ExitUpgrade.AsInt():
// Restart the monitor process to release the .old
// binary as part of the upgrade process.
l.Infoln("Restarting monitor...")
if err = restartMonitor(args); err != nil {
l.Warnln("Restart:", err)
}
return
if exiterr.ExitCode() == syncthing.ExitUpgrade.AsInt() {
// Restart the monitor process to release the .old
// binary as part of the upgrade process.
l.Infoln("Restarting monitor...")
if err = restartMonitor(args); err != nil {
l.Warnln("Restart:", err)
}
return
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/connections/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var tlsCipherSuiteNames = map[uint16]string{

var tlsVersionNames = map[uint16]string{
tls.VersionTLS12: "TLS1.2",
772: "TLS1.3", // tls.VersionTLS13 constant available in Go 1.12+
tls.VersionTLS13: "TLS1.3",
}

// Service listens and dials all configured unconnected devices, via supported
Expand Down
21 changes: 7 additions & 14 deletions lib/fs/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,16 @@ func ExpandTilde(path string) (string, error) {
}

func getHomeDir() (string, error) {
var home string

switch runtime.GOOS {
case "windows":
home = filepath.Join(os.Getenv("HomeDrive"), os.Getenv("HomePath"))
if home == "" {
home = os.Getenv("UserProfile")
if runtime.GOOS == "windows" {
// Legacy -- we prioritize this for historical reasons, whereas
// os.UserHomeDir uses %USERPROFILE% always.
home := filepath.Join(os.Getenv("HomeDrive"), os.Getenv("HomePath"))
if home != "" {
return home, nil
}
default:
home = os.Getenv("HOME")
}

if home == "" {
return "", errNoHome
}

return home, nil
return os.UserHomeDir()
}

var windowsDisallowedCharacters = string([]rune{
Expand Down
1 change: 0 additions & 1 deletion lib/tlsutil/tlsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"time"

"github.com/syncthing/syncthing/lib/build"
"github.com/syncthing/syncthing/lib/rand"
)

Expand Down

0 comments on commit 1d99e52

Please sign in to comment.