Handle exceptions when clearing temp files BECAUSE NO ONE REPORTED IT
This commit is contained in:
@@ -35,8 +35,21 @@ namespace Torch.Managers
|
||||
private void ClearTemp()
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(TempDirectory, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
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>
|
||||
/// Move the given file (if it exists) to a temporary directory that will be cleared the next time the application starts.
|
||||
|
Reference in New Issue
Block a user