Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
516a1f9b57 | |||
6b6dbdda99 | |||
54cc1d9a55 |
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
CLI tool for updating and launching [Project Epoch](https://www.project-epoch.net/) on Windows, Linux and macOS.
|
CLI tool for updating and launching [Project Epoch](https://www.project-epoch.net/) on Windows, Linux and macOS.
|
||||||
|
|
||||||
|
If you're a Linux newbie or just looking for a simpler one-click solution, check out [this excellent Lutris script](https://lutris.net/games/project-epoch/) by another community member
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
2
main.go
2
main.go
@ -49,7 +49,7 @@ func main() {
|
|||||||
log.Fatalf("WowDir in %s is still the default setting, exiting", cfgPath)
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DownloadStats struct {
|
type DownloadStats struct {
|
||||||
Updated int
|
Updated int
|
||||||
Current int
|
Current int
|
||||||
|
Outdated 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
|
var stats DownloadStats
|
||||||
|
|
||||||
manifest, err := GetManifest()
|
manifest, err := GetManifest()
|
||||||
@ -52,40 +53,44 @@ func DownloadUpdate(wowdir string, force bool, removeUnknown bool) (DownloadStat
|
|||||||
fmt.Printf("File %s is up to date\n", localPath)
|
fmt.Printf("File %s is up to date\n", localPath)
|
||||||
stats.Current += 1
|
stats.Current += 1
|
||||||
continue
|
continue
|
||||||
|
} else {
|
||||||
|
stats.Outdated += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Updating %s...\n", localPath)
|
if !skipDownload {
|
||||||
|
fmt.Printf("Updating %s...\n", localPath)
|
||||||
|
|
||||||
outFile, err := os.Create(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)
|
|
||||||
if err != nil {
|
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
|
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()
|
_, err = io.Copy(outFile, resp.Body)
|
||||||
stats.Updated += 1
|
if err != nil {
|
||||||
|
outFile.Close()
|
||||||
|
return stats, err
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
outFile.Close()
|
||||||
|
stats.Updated += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if removeUnknown {
|
if removeUnknown {
|
||||||
|
Reference in New Issue
Block a user