Skip to content

Commit f2f0c99

Browse files
committed
Refactor isGameInstalled method to improve installation checks and streamline logic
1 parent 47ffbe5 commit f2f0c99

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

internal/steamcmd/client.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,29 @@ func NewClient(steamCMDPath, steamApp, steamAppID, gameMountPath, updateScript s
3737

3838
// isGameInstalled checks if the game is already installed
3939
func (c *Client) isGameInstalled() bool {
40-
// Check if the game directory exists and contains essential files
41-
gameDir := filepath.Join(c.gameMountPath, c.steamApp)
42-
if _, err := os.Stat(gameDir); os.IsNotExist(err) {
40+
// The install root is the mount path we hand to steamcmd's force_install_dir
41+
if info, err := os.Stat(c.gameMountPath); err != nil || !info.IsDir() {
4342
return false
4443
}
4544

46-
// Check for a critical game file to confirm installation
47-
srcdsFile := filepath.Join(gameDir, "srcds_run")
48-
if _, err := os.Stat(srcdsFile); os.IsNotExist(err) {
49-
return false
45+
manifestPath := filepath.Join(c.gameMountPath, "steamapps", fmt.Sprintf("appmanifest_%s.acf", c.steamAppID))
46+
if _, err := os.Stat(manifestPath); err == nil {
47+
return true
48+
}
49+
50+
// srcds_run lives in the install root, so treat it as a secondary signal
51+
srcdsFile := filepath.Join(c.gameMountPath, "srcds_run")
52+
if _, err := os.Stat(srcdsFile); err == nil {
53+
return true
54+
}
55+
56+
// Fall back to checking the TF folder for older installs
57+
gameDir := filepath.Join(c.gameMountPath, c.steamApp)
58+
if info, err := os.Stat(gameDir); err == nil && info.IsDir() {
59+
return true
5060
}
5161

52-
return true
62+
return false
5363
}
5464

5565
// CheckUpdate checks if a TF2 update is available by comparing build IDs

0 commit comments

Comments
 (0)