diff --git a/UET/Redpoint.Uet.Core/CoreServiceExtensions.cs b/UET/Redpoint.Uet.Core/CoreServiceExtensions.cs index 82574b28..c1284e4a 100644 --- a/UET/Redpoint.Uet.Core/CoreServiceExtensions.cs +++ b/UET/Redpoint.Uet.Core/CoreServiceExtensions.cs @@ -42,6 +42,22 @@ public static void AddUETCore( options.IncludeTracing = minimumLogLevel == LogLevel.Trace; }); Directory.CreateDirectory(RunbackGlobalState.RunbackDirectoryPath); + + // Automatically delete runbacks older than 30 days so they don't consume space forever. + foreach (var file in new DirectoryInfo(RunbackGlobalState.RunbackDirectoryPath).GetFiles()) + { + if (file.LastWriteTimeUtc < DateTime.UtcNow - TimeSpan.FromDays(30)) + { + try + { + file.Delete(); + } + catch + { + } + } + } + builder.AddFile(new FileStream(RunbackGlobalState.RunbackLogPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read | FileShare.Delete)); } else