error handling, release builds

This commit is contained in:
2025-06-05 11:32:02 -07:00
parent 58f3977707
commit 027a8e073b
4 changed files with 47 additions and 22 deletions

30
main.go
View File

@ -14,9 +14,10 @@ import (
)
const (
manifestUrl = "https://updater.project-epoch.net/api/manifest"
configDirName = "epoch-linux"
configName = "config.toml"
manifestUrl = "https://updater.project-epoch.net/api/manifest"
defaultWowPath = "/path/to/wow"
configDirName = "epoch-linux"
configName = "config.toml"
)
type Config struct {
@ -27,10 +28,10 @@ var (
config Config
)
func setupConfig() {
func setupConfig() error {
home := os.Getenv("HOME")
if home == "" {
log.Fatal("$HOME environment variable not set")
return fmt.Errorf("$HOME environment variable not set")
}
cfgPath := filepath.Join(home, ".config", configDirName, configName)
@ -39,18 +40,18 @@ func setupConfig() {
os.MkdirAll(filepath.Join(home, ".config", configDirName), 0755)
newConfig := &Config{
WowDir: "/path/to/wow",
WowDir: defaultWowPath,
}
file, err := os.Create(cfgPath)
if err != nil {
log.Fatal(err)
return err
}
defer file.Close()
encoder := toml.NewEncoder(file)
if err = encoder.Encode(newConfig); err != nil {
log.Fatal(err)
return err
}
fmt.Printf("Created new config at %s, edit it before running the launcher again\n", cfgPath)
@ -59,12 +60,21 @@ func setupConfig() {
_, err := toml.DecodeFile(cfgPath, &config)
if err != nil {
log.Fatal(err)
return err
}
if config.WowDir == defaultWowPath {
return fmt.Errorf("WowDir in %s is still the default setting", cfgPath)
}
return nil
}
func main() {
setupConfig()
err := setupConfig()
if err != nil {
log.Fatal(err)
}
count, err := downloadUpdate()
if err != nil {