diff --git a/src/Recyclarr.Cli.Tests/LogJanitorTest.cs b/src/Recyclarr.Cli.Tests/LogJanitorTest.cs index 53122732..dfed8159 100644 --- a/src/Recyclarr.Cli.Tests/LogJanitorTest.cs +++ b/src/Recyclarr.Cli.Tests/LogJanitorTest.cs @@ -1,6 +1,6 @@ using System.IO.Abstractions; -using MoreLinq.Extensions; using Recyclarr.Cli.Logging; +using Recyclarr.TestLibrary; using Recyclarr.TestLibrary.AutoFixture; using Recyclarr.TrashLib.TestLibrary; @@ -17,14 +17,19 @@ public class LogJanitorTest LogJanitor janitor) { var testFiles = new[] - { - paths.LogDirectory.File("trash_2021-05-15_19-00-00.log"), - paths.LogDirectory.File("trash_2021-05-15_20-00-00.log"), - paths.LogDirectory.File("trash_2021-05-15_21-00-00.log"), - paths.LogDirectory.File("trash_2021-05-15_22-00-00.log") - }; + { + "trash_2021-05-15_19-00-00.log", + "trash_2021-05-15_20-00-00.log", + "trash_2021-05-15_21-00-00.log", + "trash_2021-05-15_22-00-00.log" + } + .Select(x => paths.LogDirectory.File(x)) + .ToList(); - testFiles.ForEach(x => fs.AddFile(x.FullName, new MockFileData(""))); + foreach (var file in testFiles) + { + fs.AddEmptyFile(file); + } janitor.DeleteOldestLogFiles(2); diff --git a/src/Recyclarr.Cli/Logging/LoggerFactory.cs b/src/Recyclarr.Cli/Logging/LoggerFactory.cs index 22ce25b4..2dba064e 100644 --- a/src/Recyclarr.Cli/Logging/LoggerFactory.cs +++ b/src/Recyclarr.Cli/Logging/LoggerFactory.cs @@ -1,5 +1,4 @@ using System.IO.Abstractions; -using Recyclarr.Common.Extensions; using Recyclarr.Common.Serilog; using Recyclarr.TrashLib; using Recyclarr.TrashLib.Startup; @@ -49,7 +48,7 @@ public class LoggerFactory public ILogger Create() { var logFilePrefix = $"recyclarr_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}"; - var logDir = _paths.LogDirectory.SubDir("cli"); + var logDir = _paths.LogDirectory; string LogFilePath(string type) { diff --git a/src/Recyclarr.TrashLib/AppPaths.cs b/src/Recyclarr.TrashLib/AppPaths.cs index bf9a8022..fd28f24d 100644 --- a/src/Recyclarr.TrashLib/AppPaths.cs +++ b/src/Recyclarr.TrashLib/AppPaths.cs @@ -1,4 +1,5 @@ using System.IO.Abstractions; +using Recyclarr.Common.Extensions; using Recyclarr.TrashLib.Startup; namespace Recyclarr.TrashLib; @@ -18,8 +19,8 @@ public class AppPaths : IAppPaths public IFileInfo ConfigPath => AppDataDirectory.File(DefaultConfigFilename); public IFileInfo SettingsPath => AppDataDirectory.File("settings.yml"); public IFileInfo SecretsPath => AppDataDirectory.File("secrets.yml"); - public IDirectoryInfo LogDirectory => AppDataDirectory.SubDirectory("logs"); - public IDirectoryInfo RepoDirectory => AppDataDirectory.SubDirectory("repo"); - public IDirectoryInfo CacheDirectory => AppDataDirectory.SubDirectory("cache"); - public IDirectoryInfo ConfigsDirectory => AppDataDirectory.SubDirectory("configs"); + public IDirectoryInfo LogDirectory => AppDataDirectory.SubDir("logs", "cli"); + public IDirectoryInfo RepoDirectory => AppDataDirectory.SubDir("repo"); + public IDirectoryInfo CacheDirectory => AppDataDirectory.SubDir("cache"); + public IDirectoryInfo ConfigsDirectory => AppDataDirectory.SubDir("configs"); }