Add Exists check and try catch when creating replay dir (#20852)

This commit is contained in:
DrSmugleaf
2023-10-14 22:01:26 +02:00
committed by Debug
parent ad64c0e8e9
commit 65a985015a
@@ -94,7 +94,17 @@ public sealed partial class GameTicker
_sawmillReplays.Info($"Moving replay into final position: {state.MoveToPath}");
_taskManager.BlockWaitOnTask(_replays.WaitWriteTasks());
DebugTools.Assert(!_replays.IsWriting());
data.Directory.CreateDir(state.MoveToPath.Value.Directory);
try
{
if (!data.Directory.Exists(state.MoveToPath.Value.Directory))
data.Directory.CreateDir(state.MoveToPath.Value.Directory);
}
catch (UnauthorizedAccessException e)
{
_sawmillReplays.Error($"Error creating replay directory {state.MoveToPath.Value.Directory}: {e}");
}
data.Directory.Rename(data.Path, state.MoveToPath.Value);
}