Skip to content

Commit

Permalink
Fixed the bug that non-existing log folder will crash the app.
Browse files Browse the repository at this point in the history
  • Loading branch information
LittlePox committed Feb 22, 2020
1 parent 8a3573a commit 33f2e45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion OKEGui/OKEGui/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("6.4.*")]
[assembly: AssemblyVersion("6.5.*")]
13 changes: 8 additions & 5 deletions OKEGui/OKEGui/Utils/Initializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,14 @@ public static bool ConfigLogger()

public static void ClearOldLogs()
{
Directory.GetFiles("log")
.Select(f => new FileInfo(f))
.Where(f => f.LastWriteTime < DateTime.Now.AddMonths(-3) || (f.LastWriteTime < DateTime.Now.AddDays(-7) && f.Length < 1024))
.ToList()
.ForEach(f => f.Delete());
if (Directory.Exists("log"))
{
Directory.GetFiles("log")
.Select(f => new FileInfo(f))
.Where(f => f.LastWriteTime < DateTime.Now.AddMonths(-3) || (f.LastWriteTime < DateTime.Now.AddDays(-7) && f.Length < 1024))
.ToList()
.ForEach(f => f.Delete());
}
}
}
}

0 comments on commit 33f2e45

Please sign in to comment.