Smarter migration logic that does a directory merge instead of a straight move. This is designed to fail less in cases like the `recyclarr` directory already existing.pull/76/head
parent
d50e08b1e3
commit
d499537f91
@ -0,0 +1,15 @@
|
|||||||
|
using System.IO.Abstractions;
|
||||||
|
|
||||||
|
namespace Recyclarr.Tests.Migration.Steps;
|
||||||
|
|
||||||
|
public class TestAppPaths : AppPaths
|
||||||
|
{
|
||||||
|
public string BasePath { get; }
|
||||||
|
|
||||||
|
public TestAppPaths(IFileSystem fs)
|
||||||
|
: base(fs)
|
||||||
|
{
|
||||||
|
BasePath = fs.Path.Combine("base", "path");
|
||||||
|
SetAppDataPath(fs.Path.Combine(BasePath, DefaultAppDataDirectoryName));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
using System.IO.Abstractions;
|
||||||
|
using Common;
|
||||||
|
using TrashLib;
|
||||||
|
|
||||||
|
namespace Recyclarr.Command.Initialization;
|
||||||
|
|
||||||
|
public class DefaultAppDataSetup : IDefaultAppDataSetup
|
||||||
|
{
|
||||||
|
private readonly IEnvironment _env;
|
||||||
|
private readonly IAppPaths _paths;
|
||||||
|
private readonly IFileSystem _fs;
|
||||||
|
|
||||||
|
public DefaultAppDataSetup(IEnvironment env, IAppPaths paths, IFileSystem fs)
|
||||||
|
{
|
||||||
|
_env = env;
|
||||||
|
_paths = paths;
|
||||||
|
_fs = fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetupDefaultPath(bool forceCreate = false)
|
||||||
|
{
|
||||||
|
var appData = _env.GetFolderPath(Environment.SpecialFolder.ApplicationData,
|
||||||
|
forceCreate ? Environment.SpecialFolderOption.Create : Environment.SpecialFolderOption.None);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(appData))
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException("Unable to find the default app data directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
_paths.SetAppDataPath(_fs.Path.Combine(appData, _paths.DefaultAppDataDirectoryName));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
namespace Recyclarr.Command.Initialization;
|
||||||
|
|
||||||
|
public interface IDefaultAppDataSetup
|
||||||
|
{
|
||||||
|
void SetupDefaultPath(bool forceCreate = false);
|
||||||
|
}
|
Loading…
Reference in new issue