parent
57c4e23dba
commit
f769c9669d
@ -0,0 +1,43 @@
|
||||
using System.IO.Abstractions;
|
||||
using JetBrains.Annotations;
|
||||
using Recyclarr.Common.Extensions;
|
||||
using Recyclarr.Platform;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Recyclarr.Cli.Migration.Steps;
|
||||
|
||||
[UsedImplicitly]
|
||||
public class MoveOsxAppDataDotnet8(
|
||||
IAppPaths paths,
|
||||
IEnvironment env,
|
||||
IRuntimeInformation runtimeInfo,
|
||||
IFileSystem fs)
|
||||
: IMigrationStep
|
||||
{
|
||||
public string Description => "Migrate OSX app data to 'Library/Application Support'";
|
||||
public IReadOnlyCollection<string> Remediation => new[]
|
||||
{
|
||||
$"Ensure Recyclarr has permission to move {OldAppDataDir} to {NewAppDataDir} and try again",
|
||||
$"Move {OldAppDataDir} to {NewAppDataDir} manually if Recyclarr can't do it"
|
||||
};
|
||||
|
||||
public bool Required => true;
|
||||
|
||||
private IDirectoryInfo OldAppDataDir => fs.DirectoryInfo
|
||||
.New(env.GetFolderPath(Environment.SpecialFolder.UserProfile))
|
||||
.SubDir(".config", AppPaths.DefaultAppDataDirectoryName);
|
||||
|
||||
private IDirectoryInfo NewAppDataDir => paths.AppDataDirectory;
|
||||
|
||||
public bool CheckIfNeeded()
|
||||
{
|
||||
return runtimeInfo.IsPlatformOsx() && OldAppDataDir.Exists;
|
||||
}
|
||||
|
||||
public void Execute(IAnsiConsole? console)
|
||||
{
|
||||
NewAppDataDir.Create();
|
||||
OldAppDataDir.MoveTo(NewAppDataDir.FullName);
|
||||
console?.WriteLine($"Moved app settings dir from '{OldAppDataDir}' to '{NewAppDataDir}'");
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Recyclarr.Platform;
|
||||
|
||||
public class DefaultRuntimeInformation : IRuntimeInformation
|
||||
{
|
||||
public bool IsPlatformOsx()
|
||||
{
|
||||
return RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
namespace Recyclarr.Platform;
|
||||
|
||||
public interface IRuntimeInformation
|
||||
{
|
||||
bool IsPlatformOsx();
|
||||
}
|
Loading…
Reference in new issue