diff options
Diffstat (limited to 'tools/updater')
| -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) +				}  			}  		}  	}  | 
