10 Commits
1.0.9 ... 1.1.0

Author SHA1 Message Date
336340269b 1.1.0 2025-08-08 09:30:16 -07:00
f8ebb74fc9 download msg 2025-08-08 09:29:16 -07:00
ccd2586c8d use channel for status messages 2025-08-08 09:27:39 -07:00
6abb9ce47a 1.0.10 2025-07-25 06:55:08 -07:00
365171fddc bugfix update logging 2025-07-24 06:57:17 -07:00
4d47056e5b fix logging 2025-07-24 06:41:58 -07:00
7f454dc632 epochsilicon 2025-07-23 08:09:49 -07:00
516a1f9b57 add outdated count 2025-07-20 21:17:33 -07:00
6b6dbdda99 add skip download 2025-07-20 21:13:40 -07:00
54cc1d9a55 Update README.md 2025-07-21 03:37:41 +00:00
4 changed files with 148 additions and 100 deletions

View File

@@ -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
@@ -16,9 +18,9 @@ A tutorial for the full setup of Epoch on Arch Linux [can be found here](https:/
### macOS ### macOS
For macOS, I've found the best way to run Wow is in a Parallels Win 11 VM. Kegworks, Codeweavers, etc crash when the game starts up and I have not found a good solution so far. Any suggestions would be welcome, see my contact information below. I currently use a Parallels VM and run the Windows version of epochcli inside the VM as an updater and launcher. For arm64 macOS (aka M1, M2 etc), I have built an app that handles all of Epoch's setup for you. [Go check it out](https://git.burkey.co/eburk/EpochSilicon)
You can easily install with homebrew or build from source yourself. I dont have time to setup codesigning right now so there are no binaries provided for macOS. For homebrew, do the following: Alternatively, you can easily install with homebrew or build from source yourself. I dont have time to setup codesigning right now so there are no binaries provided for macOS. For homebrew, do the following:
```shell ```shell
brew tap eburk/epochcli https://git.burkey.co/eburk/epochcli brew tap eburk/epochcli https://git.burkey.co/eburk/epochcli

View File

@@ -18,6 +18,9 @@ func main() {
if outOfDate { if outOfDate {
fmt.Println("There is a new version of epochcli, you must update before running") fmt.Println("There is a new version of epochcli, you must update before running")
fmt.Println("Press any key to exit...")
var c rune
fmt.Scanf("%c", &c)
os.Exit(1) os.Exit(1)
} }
@@ -49,8 +52,8 @@ 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 := epoch.Update(config.WowDir, forceFlag, config.RemoveUnknownPatches, false)
if err != nil { if stats.Error != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@@ -6,25 +6,37 @@ import (
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"log"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"slices"
"strings" "strings"
) )
type DownloadStats struct { type UpdateStats struct {
Updated int Updated int
Current int Current int
Outdated int
Error error
MessageBuf []string
} }
func DownloadUpdate(wowdir string, force bool, removeUnknown bool) (DownloadStats, error) { func Update(wowdir string, force bool, removeUnknown bool, skipDownload bool) UpdateStats {
var stats DownloadStats stats := UpdateStats{
Error: nil,
MessageBuf: make([]string, 0),
}
msgChan := make(chan string)
done := make(chan bool)
go func() {
manifest, err := GetManifest() manifest, err := GetManifest()
if err != nil { if err != nil {
log.Fatalf("Failed to get manifest: %v\n", err) stats.Error = fmt.Errorf("Failed to get manifest: %v\n", err)
done <- true
return
} }
for _, file := range manifest.Files { for _, file := range manifest.Files {
@@ -36,7 +48,9 @@ func DownloadUpdate(wowdir string, force bool, removeUnknown bool) (DownloadStat
if _, err = os.Stat(localDir); os.IsNotExist(err) { if _, err = os.Stat(localDir); os.IsNotExist(err) {
err = os.MkdirAll(localDir, 0755) err = os.MkdirAll(localDir, 0755)
if err != nil { if err != nil {
return stats, fmt.Errorf("failed to create directory %s: %v", localDir, err) stats.Error = fmt.Errorf("failed to create directory %s: %v", localDir, err)
done <- true
return
} }
} }
@@ -44,49 +58,70 @@ func DownloadUpdate(wowdir string, force bool, removeUnknown bool) (DownloadStat
if _, err = os.Stat(localPath); err == nil { if _, err = os.Stat(localPath); err == nil {
data, err := os.ReadFile(localPath) data, err := os.ReadFile(localPath)
if err != nil { if err != nil {
return stats, err stats.Error = fmt.Errorf("failed to read %s: %v", localPath, err)
done <- true
return
} }
hashBytes := md5.Sum(data) hashBytes := md5.Sum(data)
hash := hex.EncodeToString(hashBytes[:]) hash := hex.EncodeToString(hashBytes[:])
if hash == file.Hash { if hash == file.Hash {
fmt.Printf("File %s is up to date\n", localPath) msgChan <- fmt.Sprintf("File %s is up to date", localPath)
stats.Current += 1 stats.Current += 1
continue continue
} else {
stats.Outdated += 1
} }
} }
} }
fmt.Printf("Updating %s...\n", localPath) if !skipDownload {
msgChan <- fmt.Sprintf("Downloading %s", localPath)
outFile, err := os.Create(localPath) outFile, err := os.Create(localPath)
if err != nil { if err != nil {
return stats, err stats.Error = fmt.Errorf("failed to create file %s: %v", localPath, err)
done <- true
return
} }
downloadSuccess := false
for _, url := range []string{file.Urls.Cloudflare, file.Urls.Digitalocean, file.Urls.None} { for _, url := range []string{file.Urls.Cloudflare, file.Urls.Digitalocean, file.Urls.None} {
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil { if err != nil {
outFile.Close() if resp != nil {
return stats, err resp.Body.Close()
}
msgChan <- fmt.Sprintf("Failed to download %s: %v", url, err)
continue
} }
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
outFile.Close() resp.Body.Close()
return stats, fmt.Errorf("failed to download update from %s, status code: %d", url, resp.StatusCode) msgChan <- fmt.Sprintf("HTTP Status %d", resp.StatusCode)
continue
} }
_, err = io.Copy(outFile, resp.Body) _, err = io.Copy(outFile, resp.Body)
if err != nil { if err != nil {
outFile.Close() msgChan <- fmt.Sprintf("Failed to write file %s: %v", localPath, err)
return stats, err resp.Body.Close()
continue
} }
resp.Body.Close()
downloadSuccess = true
msgChan <- fmt.Sprintf("Successfully downloaded %s", localPath)
break break
} }
outFile.Close() outFile.Close()
if !downloadSuccess {
stats.Error = fmt.Errorf("Failed to download updates, see above messages")
done <- true
return
}
stats.Updated += 1 stats.Updated += 1
} }
}
if removeUnknown { if removeUnknown {
patches := make([]string, 0) patches := make([]string, 0)
@@ -101,27 +136,33 @@ func DownloadUpdate(wowdir string, force bool, removeUnknown bool) (DownloadStat
err = filepath.WalkDir(filepath.Join(wowdir, "Data"), func(path string, d fs.DirEntry, err error) error { err = filepath.WalkDir(filepath.Join(wowdir, "Data"), func(path string, d fs.DirEntry, err error) error {
if !d.IsDir() && patchreg.MatchString(d.Name()) { if !d.IsDir() && patchreg.MatchString(d.Name()) {
del := true del := true
for _, patch := range patches { if slices.Contains(patches, d.Name()) {
if patch == d.Name() {
del = false del = false
break
}
} }
if del { if del {
err = os.Remove(path) err = os.Remove(path)
if err != nil { if err != nil {
return err return err
} }
fmt.Println("Removed unknown patch", d.Name()) msgChan <- fmt.Sprintf("Removed unknown patch %s", d.Name())
} }
} }
return nil return nil
}) })
if err != nil { if err != nil {
log.Fatalf("failed to delete unknown patches: %s", err) stats.Error = fmt.Errorf("failed to delete unknown patches: %v", err)
} }
} }
done <- true
}()
return stats, nil for {
select {
case msg := <-msgChan:
fmt.Println(msg)
stats.MessageBuf = append(stats.MessageBuf, msg)
case <-done:
return stats
}
}
} }

View File

@@ -7,8 +7,10 @@ import (
"regexp" "regexp"
) )
const version = "1.0.9" const (
const versionUrl = "https://git.burkey.co/eburk/epochcli/raw/branch/master/version.go" version = "1.1.0"
versionUrl = "https://git.burkey.co/eburk/epochcli/raw/branch/master/version.go"
)
func needUpdate() (bool, error) { func needUpdate() (bool, error) {
resp, err := http.Get(versionUrl) resp, err := http.Get(versionUrl)