From 3d403ef7374ca51d8b86e81f7caebf2d45e7e277 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sat, 15 Oct 2022 15:17:16 -0500 Subject: [PATCH] feat!: Do not load config next to executable BREAKING CHANGE: The deprecated feature that still allowed you to keep your `recyclarr.yml` next to the executable has been removed. Your `recyclarr.yml` configuration file must now be located in your application data directory --- CHANGELOG.md | 7 ++ .../ConfigurationFinderTest.cs | 66 ------------------- src/Recyclarr/Command/ServiceCommand.cs | 6 +- src/Recyclarr/CompositionRoot.cs | 2 - src/Recyclarr/ConfigurationFinder.cs | 42 ------------ src/TrashLib/IConfigurationFinder.cs | 8 --- 6 files changed, 10 insertions(+), 121 deletions(-) delete mode 100644 src/Recyclarr.Tests/ConfigurationFinderTest.cs delete mode 100644 src/Recyclarr/ConfigurationFinder.cs delete mode 100644 src/TrashLib/IConfigurationFinder.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 310b0236..10838043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +This release contains **BREAKING CHANGES**. See the [Upgrade Guide][breaking3] for required changes +you need to make. + ### Removed - **BREAKING**: Completely removed support for `names` under `custom_formats` in `recyclarr.yml`. Note that this had already been deprecated for quite some time. +- **BREAKING**: The deprecated feature that still allowed you to keep your `recyclarr.yml` next to +the executable has been removed. + +[breaking3]: https://recyclarr.dev/wiki/upgrade-guide/upgrade-guide-v3.0 ## [2.6.1] - 2022-10-15 diff --git a/src/Recyclarr.Tests/ConfigurationFinderTest.cs b/src/Recyclarr.Tests/ConfigurationFinderTest.cs deleted file mode 100644 index 836cad99..00000000 --- a/src/Recyclarr.Tests/ConfigurationFinderTest.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.IO.Abstractions; -using System.IO.Abstractions.Extensions; -using System.IO.Abstractions.TestingHelpers; -using AutoFixture.NUnit3; -using Common; -using FluentAssertions; -using NSubstitute; -using NUnit.Framework; -using TestLibrary.AutoFixture; -using TrashLib.TestLibrary; - -namespace Recyclarr.Tests; - -[TestFixture] -[Parallelizable(ParallelScope.All)] -public class ConfigurationFinderTest -{ - [Test, AutoMockData] - public void Return_path_next_to_executable_if_present( - [Frozen] IAppContext appContext, - [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs, - ConfigurationFinder sut) - { - var basePath = fs.CurrentDirectory().SubDirectory("base").SubDirectory("path"); - var baseYaml = basePath.File("recyclarr.yml"); - - appContext.BaseDirectory.Returns(basePath.FullName); - fs.AddFile(baseYaml.FullName, new MockFileData("")); - - var path = sut.FindConfigPath(); - - path.FullName.Should().Be(baseYaml.FullName); - } - - [Test, AutoMockData] - public void Return_app_data_dir_location_if_base_directory_location_not_present( - [Frozen] IAppContext appContext, - [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs, - [Frozen(Matching.ImplementedInterfaces)] TestAppPaths paths, - ConfigurationFinder sut) - { - var path = sut.FindConfigPath(); - - path.FullName.Should().Be(paths.ConfigPath.FullName); - } - - [Test, AutoMockData] - public void Return_base_directory_location_if_both_files_are_present( - [Frozen] IAppContext appContext, - [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs, - ConfigurationFinder sut) - { - var appPath = fs.CurrentDirectory().SubDirectory("app").SubDirectory("data"); - var basePath = fs.CurrentDirectory().SubDirectory("base").SubDirectory("path"); - var baseYaml = basePath.File("recyclarr.yml"); - var appYaml = appPath.File("recyclarr.yml"); - - appContext.BaseDirectory.Returns(basePath.FullName); - fs.AddFile(baseYaml.FullName, new MockFileData("")); - fs.AddFile(appYaml.FullName, new MockFileData("")); - - var path = sut.FindConfigPath(); - - path.FullName.Should().Be(baseYaml.FullName); - } -} diff --git a/src/Recyclarr/Command/ServiceCommand.cs b/src/Recyclarr/Command/ServiceCommand.cs index 49a93358..98022f98 100644 --- a/src/Recyclarr/Command/ServiceCommand.cs +++ b/src/Recyclarr/Command/ServiceCommand.cs @@ -10,10 +10,10 @@ using JetBrains.Annotations; using Newtonsoft.Json; using Recyclarr.Migration; using Serilog; -using TrashLib; using TrashLib.Config.Settings; using TrashLib.Extensions; using TrashLib.Repo; +using TrashLib.Startup; using YamlDotNet.Core; namespace Recyclarr.Command; @@ -72,7 +72,7 @@ public abstract class ServiceCommand : BaseCommand, IServiceCommand var log = container.Resolve(); var settingsProvider = container.Resolve(); var repoUpdater = container.Resolve(); - var configFinder = container.Resolve(); + var paths = container.Resolve(); var migration = container.Resolve(); // Will throw if migration is required, otherwise just a warning is issued. @@ -83,7 +83,7 @@ public abstract class ServiceCommand : BaseCommand, IServiceCommand if (!Config.Any()) { - Config = new[] {configFinder.FindConfigPath().FullName}; + Config = new[] {paths.ConfigPath.FullName}; } return Task.CompletedTask; diff --git a/src/Recyclarr/CompositionRoot.cs b/src/Recyclarr/CompositionRoot.cs index 2fd75783..4d24e4c8 100644 --- a/src/Recyclarr/CompositionRoot.cs +++ b/src/Recyclarr/CompositionRoot.cs @@ -10,7 +10,6 @@ using Recyclarr.Command.Setup; using Recyclarr.Config; using Recyclarr.Logging; using Recyclarr.Migration; -using TrashLib; using TrashLib.Cache; using TrashLib.Config; using TrashLib.Config.Services; @@ -81,7 +80,6 @@ public class CompositionRoot : ICompositionRoot builder.RegisterModule(); builder.RegisterType().As(); - builder.RegisterType().As(); builder.RegisterGeneric(typeof(ConfigurationLoader<>)) .WithProperty(new AutowiringParameter()) diff --git a/src/Recyclarr/ConfigurationFinder.cs b/src/Recyclarr/ConfigurationFinder.cs deleted file mode 100644 index 696b5add..00000000 --- a/src/Recyclarr/ConfigurationFinder.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.IO.Abstractions; -using Common; -using Serilog; -using TrashLib; -using TrashLib.Startup; - -namespace Recyclarr; - -public class ConfigurationFinder : IConfigurationFinder -{ - private readonly ILogger _log; - private readonly IAppPaths _paths; - private readonly IAppContext _appContext; - private readonly IFileSystem _fs; - - public ConfigurationFinder(ILogger log, IAppPaths paths, IAppContext appContext, IFileSystem fs) - { - _log = log; - _paths = paths; - _appContext = appContext; - _fs = fs; - } - - public IFileInfo FindConfigPath() - { - var newPath = _paths.ConfigPath; - var oldPath = _fs.DirectoryInfo.FromDirectoryName(_appContext.BaseDirectory) - .File(AppPaths.DefaultConfigFilename); - - if (!oldPath.Exists) - { - return newPath; - } - - _log.Warning( - "`recyclarr.yml` file located adjacent to the executable is DEPRECATED. Please move it to the " + - "following location, as support for this old location will be removed in a future release: " + - "{NewLocation}", newPath); - - return oldPath; - } -} diff --git a/src/TrashLib/IConfigurationFinder.cs b/src/TrashLib/IConfigurationFinder.cs deleted file mode 100644 index 15af6255..00000000 --- a/src/TrashLib/IConfigurationFinder.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.IO.Abstractions; - -namespace TrashLib; - -public interface IConfigurationFinder -{ - IFileInfo FindConfigPath(); -}