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
pull/138/head
Robert Dailey 2 years ago
parent 1a4b6855a1
commit 3d403ef737

@ -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

@ -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);
}
}

@ -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<ILogger>();
var settingsProvider = container.Resolve<ISettingsProvider>();
var repoUpdater = container.Resolve<IRepoUpdater>();
var configFinder = container.Resolve<IConfigurationFinder>();
var paths = container.Resolve<IAppPaths>();
var migration = container.Resolve<IMigrationExecutor>();
// 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;

@ -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<ConfigAutofacModule>();
builder.RegisterType<ObjectFactory>().As<IObjectFactory>();
builder.RegisterType<ConfigurationFinder>().As<IConfigurationFinder>();
builder.RegisterGeneric(typeof(ConfigurationLoader<>))
.WithProperty(new AutowiringParameter())

@ -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;
}
}

@ -1,8 +0,0 @@
using System.IO.Abstractions;
namespace TrashLib;
public interface IConfigurationFinder
{
IFileInfo FindConfigPath();
}
Loading…
Cancel
Save