Skip to content

Commit

Permalink
Prevent AssetServer from crashing when Assets folder does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Terria-K committed Nov 6, 2024
1 parent b289097 commit ed681b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Riateu/Core/Assets/AssetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public AssetServer() {}

public AssetServer(string assetPath)
{
if (!Directory.Exists(assetPath))
{
Logger.Warn("AssetServer failed to watch directory, couldn't found 'Assets' folder in the root directory.");
return;
}
watcher = new FileSystemWatcher(assetPath);
watcher.EnableRaisingEvents = true;
watcher.IncludeSubdirectories = true;
Expand Down Expand Up @@ -75,7 +80,7 @@ public void Update(AssetStorage storage)

public void Dispose()
{
watcher.Dispose();
watcher?.Dispose();
Logger.Info("Asset Server finished.");
}

Expand Down

0 comments on commit ed681b6

Please sign in to comment.