From a8be14a261e3b9034a56805c8f537f730a23fa9e Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 8 Jun 2018 19:24:37 -0400 Subject: minor fixes for log file purge code (#494) --- src/SMAPI/Program.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index 570a3c55..28523722 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -1274,6 +1274,9 @@ namespace StardewModdingAPI private void PurgeLogFiles() { DirectoryInfo logsDir = new DirectoryInfo(Constants.LogDir); + if (!logsDir.Exists) + return; + foreach (FileInfo logFile in logsDir.EnumerateFiles("*.txt")) { if (logFile.Name.StartsWith(Constants.LogNamePrefix, StringComparison.InvariantCultureIgnoreCase)) @@ -1282,9 +1285,9 @@ namespace StardewModdingAPI { FileUtilities.ForceDelete(logFile); } - catch (Exception ex) + catch (IOException) { - // leave file if it's locked + // ignore file if it's in use } } } -- cgit