aboutsummaryrefslogtreecommitdiff
path: root/tools/updater/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'tools/updater/main.go')
-rw-r--r--tools/updater/main.go18
1 files changed, 15 insertions, 3 deletions
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)
+ }
}
}
}