From 185b7023c5f9367d158033e7526710d20463ba85 Mon Sep 17 00:00:00 2001 From: n00mkrad <61149547+n00mkrad@users.noreply.github.com> Date: Sat, 20 Dec 2025 23:20:16 +0100 Subject: [PATCH] More compact Cleanup --- CodeLegacy/Program.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/CodeLegacy/Program.cs b/CodeLegacy/Program.cs index f1f14ef..8523d3a 100644 --- a/CodeLegacy/Program.cs +++ b/CodeLegacy/Program.cs @@ -109,24 +109,20 @@ namespace Flowframes CleanupOldDirectories(Paths.GetSessionsPath(), keepSessionDataDays, "session"); - IoUtils.GetFilesSorted(Paths.GetPkgPath(), false, "*.log*").ToList().ForEach(x => IoUtils.TryDeleteIfExists(x)); + List delPaths = IoUtils.GetFilesSorted(Paths.GetPkgPath(), false, "*.log*").ToList(); string crashDumpsDir = Path.Combine(Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%"), "CrashDumps"); - IoUtils.GetFilesSorted(crashDumpsDir, false, "rife*.exe.*.dmp").ToList().ForEach(x => IoUtils.TryDeleteIfExists(x)); - IoUtils.GetFilesSorted(crashDumpsDir, false, "flowframes*.exe.*.dmp").ToList().ForEach(x => IoUtils.TryDeleteIfExists(x)); + delPaths.AddRange(IoUtils.GetFilesSorted(crashDumpsDir, false, "rife*.exe.*.dmp").ToList()); + delPaths.AddRange(IoUtils.GetFilesSorted(crashDumpsDir, false, "flowframes*.exe.*.dmp").ToList()); string installerTempDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FlowframesInstallerTemp"); if (Directory.Exists(installerTempDir) && (DateTime.Now - Directory.GetLastWriteTime(installerTempDir)).TotalDays > 1d) { - IoUtils.TryDeleteIfExists(installerTempDir); + delPaths.Add(installerTempDir); } - foreach (var cacheFile in IoUtils.GetFileInfosSorted(Paths.GetCachePath(), true)) - { - if ((DateTime.Now - cacheFile.LastWriteTime).TotalDays > 3d) - { - IoUtils.TryDeleteIfExists(cacheFile.FullName); - } - } + delPaths.AddRange(IoUtils.GetFileInfosSorted(Paths.GetCachePath(), true).Where(cf => (DateTime.Now - cf.LastWriteTime).TotalDays > 3d).Select(cf => cf.FullName)); + + delPaths.ForEach(p => IoUtils.TryDeleteIfExists(p)); } catch (Exception e) {