From 22e2cc088cec4199189fb4ae9b8e2fd190de78e5 Mon Sep 17 00:00:00 2001 From: Trit0 Date: Sun, 29 Jun 2025 18:23:25 -0400 Subject: [PATCH 1/3] stupid mistake --- lib/provider/provider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/provider/provider.go b/lib/provider/provider.go index b7036da..bebac4d 100644 --- a/lib/provider/provider.go +++ b/lib/provider/provider.go @@ -147,7 +147,7 @@ func extractZipsInFolder(folder string) error { if entry.IsDir() { continue } - if strings.HasSuffix(strings.ToLower(entry.Name()), ".conj") { + if strings.HasSuffix(strings.ToLower(entry.Name()), ".zip") { zipPath := filepath.Join(folder, entry.Name()) fmt.Println("Extracting:", zipPath) if err := extractZipToSiblingFolder(zipPath); err != nil { From b46eefa34a7233335a3e9aec6ae44a70769f5c66 Mon Sep 17 00:00:00 2001 From: Trit0 Date: Sun, 29 Jun 2025 18:35:33 -0400 Subject: [PATCH 2/3] images perchance? --- lib/provider/provider.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/provider/provider.go b/lib/provider/provider.go index bebac4d..9e09110 100644 --- a/lib/provider/provider.go +++ b/lib/provider/provider.go @@ -73,6 +73,7 @@ func GetOrSetEnvKey(key string, defaultValue string) string { func extractZipToSiblingFolder(zipPath string) error { // Determine destination folder name (same name as zip file, without .zip) zipBase := strings.TrimSuffix(filepath.Base(zipPath), ".conj") + zipBase = strings.TrimSuffix(filepath.Base(zipBase), ".zip") destDir := filepath.Join(filepath.Dir(zipPath), zipBase) // Delete destination folder if it exists @@ -186,14 +187,14 @@ func GetConjureGameInfo() []models.Game { newGames := readFolder(e, gamePath) games = append(newGames, games...) } else if filepath.Ext(e.Name()) == ".conj" { - zipPath := filepath.Join(gamePath, e.Name()) - r, err := zip.OpenReader(zipPath) + conjPath := filepath.Join(gamePath, e.Name()) + r, err := zip.OpenReader(conjPath) if err != nil { log.Fatal(err) } defer r.Close() - fmt.Println("Contents of", zipPath) + fmt.Println("Contents of", conjPath) for _, f := range r.File { printIndentedPath(f.Name) if f.Name == "metadata.txt" { @@ -206,6 +207,9 @@ func GetConjureGameInfo() []models.Game { fmt.Println("Contents of metadata.txt:") metadata, err := io.ReadAll(rc) game := parseGameInfo(metadata) + conjBase := strings.TrimSuffix(filepath.Base(conjPath), ".conj") + game.ThumbnailPath = filepath.Join(conjBase, game.ThumbnailPath) + game.ImagePath = filepath.Join(conjBase, game.ImagePath) games = append(games, game) if err != nil { log.Fatal(err) From 5a2a070f6439426758385fbb431597f30435d053 Mon Sep 17 00:00:00 2001 From: Trit0 Date: Sun, 29 Jun 2025 18:58:11 -0400 Subject: [PATCH 3/3] images perchance? 3 --- lib/provider/provider.go | 46 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/lib/provider/provider.go b/lib/provider/provider.go index 9e09110..c203830 100644 --- a/lib/provider/provider.go +++ b/lib/provider/provider.go @@ -161,10 +161,13 @@ func extractZipsInFolder(folder string) error { } func ExtractGame(game models.Game) string { - gamePath := filepath.Join(config.GetDefaultConjureGamesDirectory(), fmt.Sprintf("%s.conj", game.Id)) - err := extractZipToSiblingFolder(gamePath) - check(err) - gamePath = filepath.Join(config.GetDefaultConjureGamesDirectory(), game.Id) + info, err := os.Stat(filepath.Join(config.GetDefaultConjureGamesDirectory(), game.Id)) + if err != nil || !info.IsDir() { + gamePath := filepath.Join(config.GetDefaultConjureGamesDirectory(), fmt.Sprintf("%s.conj", game.Id)) + err = extractZipToSiblingFolder(gamePath) + check(err) + } + gamePath := filepath.Join(config.GetDefaultConjureGamesDirectory(), game.Id) err = extractZipsInFolder(gamePath) check(err) gamePath = filepath.Join(gamePath, game.Files) @@ -175,47 +178,40 @@ func GetConjureGameInfo() []models.Game { gamePath := config.GetDefaultConjureGamesDirectory() - entrie, err := os.ReadDir(gamePath) + entries, err := os.ReadDir(gamePath) if err != nil { log.Fatal(err) } var games []models.Game - for _, e := range entrie { + for _, e := range entries { if e.IsDir() { - newGames := readFolder(e, gamePath) - games = append(newGames, games...) + continue } else if filepath.Ext(e.Name()) == ".conj" { conjPath := filepath.Join(gamePath, e.Name()) - r, err := zip.OpenReader(conjPath) - if err != nil { - log.Fatal(err) - } - defer r.Close() - + err = extractZipToSiblingFolder(conjPath) + check(err) + conjBase := strings.TrimSuffix(conjPath, ".conj") + entries, err := os.ReadDir(conjBase) + check(err) fmt.Println("Contents of", conjPath) - for _, f := range r.File { - printIndentedPath(f.Name) - if f.Name == "metadata.txt" { - rc, err := f.Open() - if err != nil { - log.Fatal(err) - } + for _, f := range entries { + if f.Name() == "metadata.txt" { + rc, err := os.Open(filepath.Join(conjBase, f.Name())) + check(err) defer rc.Close() fmt.Println("Contents of metadata.txt:") metadata, err := io.ReadAll(rc) game := parseGameInfo(metadata) - conjBase := strings.TrimSuffix(filepath.Base(conjPath), ".conj") game.ThumbnailPath = filepath.Join(conjBase, game.ThumbnailPath) game.ImagePath = filepath.Join(conjBase, game.ImagePath) games = append(games, game) - if err != nil { - log.Fatal(err) - } + check(err) } } + } }