feat: loader logic

This commit is contained in:
Ilia Denisov
2026-03-15 21:57:42 +02:00
parent 6179dadb5e
commit cc7ecf6667
5 changed files with 117 additions and 96 deletions
+11 -4
View File
@@ -163,10 +163,10 @@ func (s *fsStorage) SaveOrderAsync(id client.GameID, turn uint, o order.Order, c
}()
}
func (s *fsStorage) FileExists(path string) (bool, error) {
func (s *fsStorage) FileExists(path string) (bool, string, error) {
absPath, err := s.resolvePath(path)
if err != nil {
return false, err
return false, "", err
}
var exists bool
@@ -175,7 +175,13 @@ func (s *fsStorage) FileExists(path string) (bool, error) {
exists, opErr = s.fileExistsUnlocked(absPath)
return opErr
})
return exists, err
if err != nil {
return false, "", err
}
if !exists {
return false, "", nil
}
return true, absPath, nil
}
func (s *fsStorage) ReadFile(path string) ([]byte, error) {
@@ -254,7 +260,8 @@ func (s *fsStorage) ListFiles() ([]string, error) {
}
func (s *fsStorage) StateExists() (bool, error) {
return s.FileExists(stateFileName)
exists, _, err := s.FileExists(stateFileName)
return exists, err
}
func (s *fsStorage) LoadState() (client.State, error) {