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 directorypull/138/head
parent
1a4b6855a1
commit
3d403ef737
@ -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);
|
||||
}
|
||||
}
|
@ -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…
Reference in new issue