diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-09-30 11:30:17 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-09-30 16:16:55 +0200 |
commit | 8f8f3d571fc702fd31c1008c8ec056c3741b3e35 (patch) | |
tree | ec9440e6c0ef708b237f85f824a8b243bc00a75b /tools | |
parent | ProfileManager: move initial profile loading to ProfileManager (diff) | |
download | smolbote-8f8f3d571fc702fd31c1008c8ec056c3741b3e35.tar.xz |
updater: windows fixes
- fix .part rename
- add press enter pause to panics
Diffstat (limited to 'tools')
-rw-r--r-- | tools/updater/download.go | 6 | ||||
-rw-r--r-- | tools/updater/main.go | 18 |
2 files changed, 17 insertions, 7 deletions
diff --git a/tools/updater/download.go b/tools/updater/download.go index 2adfe41..8c9de9a 100644 --- a/tools/updater/download.go +++ b/tools/updater/download.go @@ -83,8 +83,6 @@ func downloadFile(path string, url string) error { } fmt.Printf("\n") - //fmt.Printf("\r%s", strings.Repeat(" ", 40)) - os.Rename(path+".part", path) - //fmt.Printf("\r[%s] complete\n", path) - return nil + output.Close() + return os.Rename(path+".part", path) } diff --git a/tools/updater/main.go b/tools/updater/main.go index deaad87..baef1f1 100644 --- a/tools/updater/main.go +++ b/tools/updater/main.go @@ -5,10 +5,20 @@ import ( "flag" "fmt" "net/http" + "os" "runtime" "strings" ) +func fail(err error) { + fmt.Printf("An error has occurred:\n%s\n", err.Error()) + if runtime.GOOS == "windows" { + fmt.Print("Press 'Enter' to continue...") + fmt.Scanln() + } + os.Exit(-1) +} + func main() { helpFlag := flag.Bool("help", false, "Show help information") verboseFlag := flag.Bool("verbose", false, "Print more information") @@ -34,7 +44,7 @@ func main() { response, err := http.Get(manifestPath) if err != nil { - panic(err) + fail(err) } else if response.StatusCode != 200 { fmt.Printf("Could not get manifest: %s\n", response.Status) return @@ -50,14 +60,16 @@ func main() { checksum := s[0] if same, err := checkFile(filepath, checksum); err != nil { - panic(err) + fail(err) } else { if *verboseFlag { fmt.Printf("[%s]: %t\n", filepath, same) } if !same && !*dryRunFlag { - downloadFile(filepath, repoPath+filepath) + if err := downloadFile(filepath, repoPath+filepath); err != nil { + fail(err) + } } } } |