Handle exceptions when clearing temp files BECAUSE NO ONE REPORTED IT

This commit is contained in:
Brant Martin
2019-09-25 17:36:16 -04:00
parent 792151a8b7
commit e4ad517cb1

View File

@@ -35,7 +35,20 @@ namespace Torch.Managers
private void ClearTemp()
{
foreach (var file in Directory.GetFiles(TempDirectory, "*", SearchOption.AllDirectories))
File.Delete(file);
{
try
{
File.Delete(file);
}
catch (UnauthorizedAccessException)
{
_log.Debug($"Failed to delete file {file}, it's probably in use by another process'");
}
catch (Exception ex)
{
_log.Warn($"Unhandled exception when clearing temp files. You may ignore this. {ex}");
}
}
}
/// <summary>