parent
b26cd3bd5a
commit
010c788e14
@ -1,13 +0,0 @@
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Recyclarr.Cli.Migration;
|
||||
|
||||
public interface IMigrationStep
|
||||
{
|
||||
int Order { get; }
|
||||
string Description { get; }
|
||||
IReadOnlyCollection<string> Remediation { get; }
|
||||
bool Required { get; }
|
||||
bool CheckIfNeeded();
|
||||
void Execute(IAnsiConsole? console);
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
using System.IO.Abstractions;
|
||||
using JetBrains.Annotations;
|
||||
using Recyclarr.Common.Extensions;
|
||||
using Recyclarr.TrashLib.Startup;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Recyclarr.Cli.Migration.Steps;
|
||||
|
||||
[UsedImplicitly]
|
||||
public class DeleteRepoDirMigrationStep : IMigrationStep
|
||||
{
|
||||
private readonly IAppPaths _paths;
|
||||
|
||||
public DeleteRepoDirMigrationStep(IAppPaths paths)
|
||||
{
|
||||
_paths = paths;
|
||||
}
|
||||
|
||||
public int Order => 1;
|
||||
public string Description => "Delete old repo directory";
|
||||
public IReadOnlyCollection<string> Remediation => new[]
|
||||
{
|
||||
$"Ensure Recyclarr has permission to recursively delete {RepoDir}",
|
||||
$"Delete {RepoDir} manually if Recyclarr can't do it"
|
||||
};
|
||||
|
||||
public bool Required => false;
|
||||
private IDirectoryInfo RepoDir => _paths.AppDataDirectory.SubDir("repo");
|
||||
|
||||
public bool CheckIfNeeded()
|
||||
{
|
||||
return RepoDir.Exists;
|
||||
}
|
||||
|
||||
public void Execute(IAnsiConsole? console)
|
||||
{
|
||||
RepoDir.RecursivelyDeleteReadOnly();
|
||||
console?.WriteLine($"Deleted repo dir: {RepoDir.FullName}");
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Recyclarr.Cli.Migration.Steps;
|
||||
|
||||
public interface IMigrationStep
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines the order in which this migration step will run.
|
||||
/// </summary>
|
||||
int Order { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A description printed to the user so that they understand the purpose of this migration step, and
|
||||
/// what it does.
|
||||
/// </summary>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// One or more strings that individually represent a distinct manual solution that a user can attempt
|
||||
/// when this migration step fails.
|
||||
/// </summary>
|
||||
IReadOnlyCollection<string> Remediation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if this migration step is required. If so, it must be executed before the program may be
|
||||
/// used normally.
|
||||
/// </summary>
|
||||
bool Required { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Run logic to determine if this migration step is necessary
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Return true if this migration step is needed and should be run. False means the migration step is
|
||||
/// not needed and Execute() will not be called.
|
||||
/// </returns>
|
||||
bool CheckIfNeeded();
|
||||
|
||||
/// <summary>
|
||||
/// Execute the logic necessary for this migration step.
|
||||
/// </summary>
|
||||
/// <param name="console">
|
||||
/// Use the console to print additional debug diagnostics. If this parameter is null, that means those
|
||||
/// diagnostics should not be printed.
|
||||
/// </param>
|
||||
void Execute(IAnsiConsole? console);
|
||||
}
|
Loading…
Reference in new issue