Handle exceptions when clearing temp files BECAUSE NO ONE REPORTED IT
This commit is contained in:
@@ -35,7 +35,20 @@ namespace Torch.Managers
|
|||||||
private void ClearTemp()
|
private void ClearTemp()
|
||||||
{
|
{
|
||||||
foreach (var file in Directory.GetFiles(TempDirectory, "*", SearchOption.AllDirectories))
|
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>
|
/// <summary>
|
||||||
|
Reference in New Issue
Block a user