diff --git a/src/Recyclarr.Tests/Migration/Steps/MigrateTrashUpdaterAppDataDirTest.cs b/src/Recyclarr.Tests/Migration/Steps/MigrateTrashUpdaterAppDataDirTest.cs index d2f92d95..c36fd883 100644 --- a/src/Recyclarr.Tests/Migration/Steps/MigrateTrashUpdaterAppDataDirTest.cs +++ b/src/Recyclarr.Tests/Migration/Steps/MigrateTrashUpdaterAppDataDirTest.cs @@ -4,6 +4,7 @@ using AutoFixture.NUnit3; using FluentAssertions; using NUnit.Framework; using Recyclarr.Migration.Steps; +using TestLibrary; using TestLibrary.AutoFixture; namespace Recyclarr.Tests.Migration.Steps; @@ -52,11 +53,19 @@ public class MigrateTrashUpdaterAppDataDirTest MigrateTrashUpdaterAppDataDir sut) { // Add file instead of directory since the migration step only operates on files - fs.AddFile(fs.Path.Combine(paths.BasePath, "trash-updater", "1", "2", "test.txt"), new MockFileData("")); + fs.AddFileNoData($"{paths.BasePath}/trash-updater/settings.yml"); + fs.AddFileNoData($"{paths.BasePath}/trash-updater/recyclarr.yml"); + fs.AddFileNoData($"{paths.BasePath}/trash-updater/this-gets-ignored.yml"); + fs.AddDirectory2($"{paths.BasePath}/trash-updater/repo"); + fs.AddDirectory2($"{paths.BasePath}/trash-updater/cache"); + fs.AddFileNoData($"{paths.BasePath}/trash-updater/cache/sonarr/test.txt"); sut.Execute(null); fs.AllDirectories.Should().NotContain(x => x.Contains("trash-updater")); - fs.AllFiles.Should().Contain(x => Regex.IsMatch(x, @"[/\\]recyclarr[/\\]1[/\\]2[/\\]test.txt$")); + fs.AllFiles.Should().BeEquivalentTo( + FileUtils.NormalizePath($"/{paths.BasePath}/recyclarr/settings.yml"), + FileUtils.NormalizePath($"/{paths.BasePath}/recyclarr/recyclarr.yml"), + FileUtils.NormalizePath($"/{paths.BasePath}/recyclarr/cache/sonarr/test.txt")); } } diff --git a/src/Recyclarr/Migration/Steps/MigrateTrashUpdaterAppDataDir.cs b/src/Recyclarr/Migration/Steps/MigrateTrashUpdaterAppDataDir.cs index db14ebdb..b87f71e1 100644 --- a/src/Recyclarr/Migration/Steps/MigrateTrashUpdaterAppDataDir.cs +++ b/src/Recyclarr/Migration/Steps/MigrateTrashUpdaterAppDataDir.cs @@ -42,5 +42,25 @@ public class MigrateTrashUpdaterAppDataDir : IMigrationStep public bool CheckIfNeeded() => _fs.Directory.Exists(GetOldPath()); - public void Execute(IConsole? console) => _fs.MergeDirectory(GetOldPath(), GetNewPath(), console); + public void Execute(IConsole? console) + { + _fs.MergeDirectory( + _fs.Path.Combine(GetOldPath(), "cache"), + _fs.Path.Combine(GetNewPath(), "cache"), + console); + + MoveFile("recyclarr.yml"); + MoveFile("settings.yml"); + + _fs.Directory.Delete(GetOldPath(), true); + } + + private void MoveFile(string file) + { + var recyclarrYaml = _fs.FileInfo.FromFileName(_fs.Path.Combine(GetOldPath(), file)); + if (recyclarrYaml.Exists) + { + recyclarrYaml.MoveTo(_fs.Path.Combine(GetNewPath(), file)); + } + } }