aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/api_map.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/api_map.go')
-rw-r--r--internal/admin/api_map.go48
1 files changed, 11 insertions, 37 deletions
diff --git a/internal/admin/api_map.go b/internal/admin/api_map.go
index 5de41a7..7298f1e 100644
--- a/internal/admin/api_map.go
+++ b/internal/admin/api_map.go
@@ -44,7 +44,6 @@ func (s *AdminServer) handleMap(w http.ResponseWriter, r *http.Request) {
Y int `json:"y"`
Name string `json:"name"`
Color string `json:"color"`
- Symbol string `json:"symbol"`
}
type LinkEntry struct {
@@ -249,47 +248,22 @@ func findDisconnectedRooms(s *AdminServer, dir string, seed int, g world.RoomGri
func listRoomIDsInDir(s *AdminServer, dir string) []int {
base := filepath.Join(s.dataDir, "rooms")
- var dirs []string
- if dir == "" {
- dirs = append(dirs, base)
- entries, err := os.ReadDir(base)
- if err != nil {
- return nil
- }
- for _, e := range entries {
- if e.IsDir() {
- dirs = append(dirs, filepath.Join(base, e.Name()))
- subE, err := os.ReadDir(filepath.Join(base, e.Name()))
- if err != nil {
- continue
- }
- for _, se := range subE {
- if se.IsDir() {
- dirs = append(dirs, filepath.Join(base, e.Name(), se.Name()))
- }
- }
- }
- }
- } else {
- dirs = append(dirs, filepath.Join(base, dir))
+ walkRoot := base
+ if dir != "" {
+ walkRoot = filepath.Join(base, dir)
}
var ids []int
- for _, d := range dirs {
- entries, err := os.ReadDir(d)
- if err != nil {
- continue
+ filepath.WalkDir(walkRoot, func(path string, d os.DirEntry, err error) error {
+ if err != nil || d.IsDir() || filepath.Ext(d.Name()) != ".yaml" {
+ return nil
}
- for _, e := range entries {
- if e.IsDir() || filepath.Ext(e.Name()) != ".yaml" {
- continue
- }
- id, err := strconv.Atoi(e.Name()[:len(e.Name())-5])
- if err != nil {
- continue
- }
+ name := d.Name()
+ id, convErr := strconv.Atoi(name[:len(name)-5])
+ if convErr == nil && id > 0 {
ids = append(ids, id)
}
- }
+ return nil
+ })
return ids
}