diff --git a/main.go b/main.go index ee8bc7a..55ad1d9 100644 --- a/main.go +++ b/main.go @@ -35,7 +35,7 @@ func saveToken(tok *oauth2.Token, filename string) { if err != nil { log.Fatalf("Failed to marshal token: %v", err) } - err = ioutil.WriteFile(filename, j, 0664) + err = ioutil.WriteFile(filename, j, 0600) if err != nil { log.Fatalf("Failed to save token: %v", err) } @@ -215,36 +215,39 @@ func getDownloadLinks(p *Product) []*DownloadLinks { } func sanitizeName(name string) string { - s := strings.Replace(name, " ", "_", -1) - s = strings.Replace(s, "'", "", -1) - s = strings.Replace(s, "™", "", -1) + // s := strings.Replace(name, " ", "_", -1) + // s = strings.Replace(s, "'", "", -1) + // s = strings.Replace(s, "™", "", -1) + re := regexp.MustCompile("[^0-1a-zA-Z.-_]+") + s := name + s = re.ReplaceAllString(s, "_") return s } -func writeChecksumIfNeeded(dl *DownloadLinks, folder string) { - // TODO: reuse an existing checksum file somehow - res, err := client.Get(dl.Checksum) - if err != nil { - log.Fatalf("Failed to get file checksum info: %v", err) - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - log.Fatalf("Failed to parse file checksum body: %v", err) - } +// func writeChecksumIfNeeded(dl *DownloadLinks, folder string) { +// // TODO: reuse an existing checksum file somehow +// res, err := client.Get(dl.Checksum) +// if err != nil { +// log.Fatalf("Failed to get file checksum info (%s): %v", dl.Checksum, err) +// } +// defer res.Body.Close() +// body, err := ioutil.ReadAll(res.Body) +// if err != nil { +// log.Fatalf("Failed to parse file checksum body (%s): %v", dl.Checksum, err) +// } - re := regexp.MustCompile(`