Skip to content

Commit 3b15f73

Browse files
authored
Automatically delete runback files older than 30 days (#47)
1 parent 49a32e5 commit 3b15f73

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

UET/Redpoint.Uet.Core/CoreServiceExtensions.cs

+16
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ public static void AddUETCore(
4242
options.IncludeTracing = minimumLogLevel == LogLevel.Trace;
4343
});
4444
Directory.CreateDirectory(RunbackGlobalState.RunbackDirectoryPath);
45+
46+
// Automatically delete runbacks older than 30 days so they don't consume space forever.
47+
foreach (var file in new DirectoryInfo(RunbackGlobalState.RunbackDirectoryPath).GetFiles())
48+
{
49+
if (file.LastWriteTimeUtc < DateTime.UtcNow - TimeSpan.FromDays(30))
50+
{
51+
try
52+
{
53+
file.Delete();
54+
}
55+
catch
56+
{
57+
}
58+
}
59+
}
60+
4561
builder.AddFile(new FileStream(RunbackGlobalState.RunbackLogPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read | FileShare.Delete));
4662
}
4763
else

0 commit comments

Comments
 (0)