add skip download

This commit is contained in:
2025-07-20 21:13:07 -07:00
parent 54cc1d9a55
commit 6b6dbdda99
2 changed files with 28 additions and 26 deletions

View File

@ -49,7 +49,7 @@ func main() {
log.Fatalf("WowDir in %s is still the default setting, exiting", cfgPath)
}
stats, err := epoch.DownloadUpdate(config.WowDir, forceFlag, config.RemoveUnknownPatches)
stats, err := epoch.Update(config.WowDir, forceFlag, config.RemoveUnknownPatches, false)
if err != nil {
log.Fatal(err)
}

View File

@ -19,7 +19,7 @@ type DownloadStats struct {
Current int
}
func DownloadUpdate(wowdir string, force bool, removeUnknown bool) (DownloadStats, error) {
func Update(wowdir string, force bool, removeUnknown bool, skipDownload bool) (DownloadStats, error) {
var stats DownloadStats
manifest, err := GetManifest()
@ -56,36 +56,38 @@ func DownloadUpdate(wowdir string, force bool, removeUnknown bool) (DownloadStat
}
}
fmt.Printf("Updating %s...\n", localPath)
if !skipDownload {
fmt.Printf("Updating %s...\n", localPath)
outFile, err := os.Create(localPath)
if err != nil {
return stats, err
}
for _, url := range []string{file.Urls.Cloudflare, file.Urls.Digitalocean, file.Urls.None} {
resp, err := http.Get(url)
outFile, err := os.Create(localPath)
if err != nil {
outFile.Close()
return stats, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
outFile.Close()
return stats, fmt.Errorf("failed to download update from %s, status code: %d", url, resp.StatusCode)
}
_, err = io.Copy(outFile, resp.Body)
if err != nil {
outFile.Close()
return stats, err
}
break
}
for _, url := range []string{file.Urls.Cloudflare, file.Urls.Digitalocean, file.Urls.None} {
resp, err := http.Get(url)
if err != nil {
outFile.Close()
return stats, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
outFile.Close()
return stats, fmt.Errorf("failed to download update from %s, status code: %d", url, resp.StatusCode)
}
outFile.Close()
stats.Updated += 1
_, err = io.Copy(outFile, resp.Body)
if err != nil {
outFile.Close()
return stats, err
}
break
}
outFile.Close()
stats.Updated += 1
}
}
if removeUnknown {