Skip to content

Commit 686620f

Browse files
committed
Fix Tootmaker loader crashing on Mac
1 parent a36310b commit 686620f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

BaboonAPI/internal/Tootmaker.fs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,20 @@ type internal TootmakerTrackRegistry(path: string, localizer: StringLocalizer, s
132132

133133
interface TrackRegistrationEvent.Listener with
134134
member this.OnRegisterTracks() = seq {
135-
let folders = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly)
136-
for folderPath in folders do
137-
let songPath = Path.Combine(folderPath, "song.tmb")
138-
if File.Exists songPath then
139-
use stream = File.OpenText songPath
140-
use reader = new JsonTextReader(stream)
141-
let data = serializer.Deserialize<SongDataCustom> reader
142-
yield TootmakerTrack (data, folderPath)
135+
if Directory.Exists path then
136+
let folders = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly)
137+
for folderPath in folders do
138+
let songPath = Path.Combine(folderPath, "song.tmb")
139+
if File.Exists songPath then
140+
use stream = File.OpenText songPath
141+
use reader = new JsonTextReader(stream)
142+
let data = serializer.Deserialize<SongDataCustom> reader
143+
yield TootmakerTrack (data, folderPath)
143144
}
144145

145146
interface TrackCollectionRegistrationEvent.Listener with
146147
member this.OnRegisterCollections() =
147-
Seq.singleton (TootmakerCollection (path, localizer, sprites))
148+
if Directory.Exists path then
149+
Seq.singleton (TootmakerCollection (path, localizer, sprites))
150+
else
151+
Seq.empty

0 commit comments

Comments
 (0)