aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/Updater.md1
-rw-r--r--tools/updater/download.go6
-rw-r--r--tools/updater/main.go18
3 files changed, 18 insertions, 7 deletions
diff --git a/doc/Updater.md b/doc/Updater.md
index 595ec9c..899240f 100644
--- a/doc/Updater.md
+++ b/doc/Updater.md
@@ -3,6 +3,7 @@
### Manifest
~~~sh
find windows/ -type f | xargs sha512sum | sed 's/windows\///' > windows-sha512.txt
+find windows/ -type d -exec chmod 755 {} +
~~~
### Building
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)
+ }
}
}
}