diff --git a/EftPatchHelper/EftPatchHelper/EftPatchHelper.csproj b/EftPatchHelper/EftPatchHelper/EftPatchHelper.csproj
index 417a821..5f81d29 100644
--- a/EftPatchHelper/EftPatchHelper/EftPatchHelper.csproj
+++ b/EftPatchHelper/EftPatchHelper/EftPatchHelper.csproj
@@ -5,8 +5,8 @@
net6.0
enable
enable
- 1.3.6
- 1.3.6
+ 1.3.8
+ 1.3.8
diff --git a/EftPatchHelper/EftPatchHelper/Interfaces/ICleanupTask.cs b/EftPatchHelper/EftPatchHelper/Interfaces/ICleanupTask.cs
new file mode 100644
index 0000000..3c21910
--- /dev/null
+++ b/EftPatchHelper/EftPatchHelper/Interfaces/ICleanupTask.cs
@@ -0,0 +1,6 @@
+namespace EftPatchHelper.Interfaces
+{
+ public interface ICleanupTask : ITaskable
+ {
+ }
+}
diff --git a/EftPatchHelper/EftPatchHelper/Program.cs b/EftPatchHelper/EftPatchHelper/Program.cs
index efbd454..0708030 100644
--- a/EftPatchHelper/EftPatchHelper/Program.cs
+++ b/EftPatchHelper/EftPatchHelper/Program.cs
@@ -14,6 +14,7 @@ namespace EftPatchHelper
{
ITaskable _settingsTasks;
ITaskable _clientSelectionTasks;
+ ITaskable _cleanupTasks;
ITaskable _fileProcessingTasks;
ITaskable _patchGenTasks;
ITaskable _patchTestingTasks;
@@ -36,6 +37,7 @@ namespace EftPatchHelper
public Program(
ISettingsTask settingsTasks,
IClientSelectionTask clientSelectionTasks,
+ ICleanupTask cleanupTasks,
IFileProcessingTasks fileProcessingTasks,
IPatchGenTasks patchGenTasks,
IPatchTestingTasks patchTestingTasks,
@@ -45,6 +47,7 @@ namespace EftPatchHelper
{
_settingsTasks = settingsTasks;
_clientSelectionTasks = clientSelectionTasks;
+ _cleanupTasks = cleanupTasks;
_fileProcessingTasks = fileProcessingTasks;
_patchGenTasks = patchGenTasks;
_patchTestingTasks = patchTestingTasks;
@@ -56,6 +59,7 @@ namespace EftPatchHelper
{
_settingsTasks.Run();
_clientSelectionTasks.Run();
+ _cleanupTasks.Run();
_fileProcessingTasks.Run();
_patchGenTasks.Run();
_patchTestingTasks.Run();
@@ -79,6 +83,7 @@ namespace EftPatchHelper
services.AddScoped();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
diff --git a/EftPatchHelper/EftPatchHelper/Tasks/CleanupTask.cs b/EftPatchHelper/EftPatchHelper/Tasks/CleanupTask.cs
new file mode 100644
index 0000000..45f7f62
--- /dev/null
+++ b/EftPatchHelper/EftPatchHelper/Tasks/CleanupTask.cs
@@ -0,0 +1,105 @@
+using EftPatchHelper.Interfaces;
+using EftPatchHelper.Model;
+using Spectre.Console;
+
+namespace EftPatchHelper.Tasks
+{
+ public class CleanupTask : ICleanupTask
+ {
+ private Settings _settings;
+ private Options _options;
+
+ List _fileToRemove = new List();
+
+ public CleanupTask(Settings settings, Options options)
+ {
+ _settings = settings;
+ _options = options;
+ }
+
+ private void GetPathsToRemove()
+ {
+ var prepFolders = Directory.GetDirectories(_settings.PrepFolderPath, "*");
+
+ foreach (var prepFolder in prepFolders)
+ {
+ if (prepFolder == _options.TargetClient.PrepPath)
+ continue;
+
+ _fileToRemove.Add(new DirectoryInfo(prepFolder));
+ }
+
+ var mirrorsPath = Path.Join(Environment.CurrentDirectory, "mirrors.json");
+ var hubentries = Directory.GetFiles(Environment.CurrentDirectory, "hubEntry_*.txt");
+
+ if (File.Exists(mirrorsPath))
+ _fileToRemove.Add(new FileInfo(mirrorsPath));
+
+ _fileToRemove.AddRange(hubentries.Select(x => new FileInfo(x)));
+
+ var patcherDir = new FileInfo(_settings.PatcherEXEPath).Directory;
+
+ _fileToRemove.AddRange(patcherDir.GetFiles().Where(x => x.FullName != _settings.PatcherEXEPath));
+ _fileToRemove.AddRange(patcherDir.GetDirectories("*", SearchOption.TopDirectoryOnly));
+ }
+
+ private void RemoveData(Table table)
+ {
+ AnsiConsole.Live(table).Start(ctx =>
+ {
+ for (int i = 0; i < _fileToRemove.Count; i++)
+ {
+ table.UpdateCell(i, 0, "[white]Removing ...[/]");
+
+ ctx.Refresh();
+
+ var item = _fileToRemove[i];
+
+ if (item is DirectoryInfo dir)
+ dir.Delete(true);
+
+ if (item is FileInfo file)
+ file.Delete();
+
+
+ table.UpdateCell(i, 0, item.Exists ? "[red]Exists[/]" : "[green]Removed[/]");
+ ctx.Refresh();
+ }
+ });
+
+ AnsiConsole.Write(new Rule());
+ }
+
+ public void Run()
+ {
+ GetPathsToRemove();
+
+ if (_fileToRemove.Count == 0)
+ return;
+
+ Table removableFilesTable = new Table()
+ .Alignment(Justify.Center)
+ .AddColumn("Status")
+ .AddColumn("File Name")
+ .AddColumn("Full Path")
+ .BorderStyle(Style.Parse("blue"));
+
+ foreach (var file in _fileToRemove)
+ {
+ removableFilesTable.AddRow("[grey]Exists[/]", file.Name, file.FullName);
+ }
+
+ var cursorPos = Console.GetCursorPosition();
+
+ AnsiConsole.Write(removableFilesTable);
+
+
+ var removeFiles = new ConfirmationPrompt("Run cleanup to remove files shown above?").Show(AnsiConsole.Console);
+
+ Console.SetCursorPosition(cursorPos.Left, cursorPos.Top);
+
+ if (removeFiles)
+ RemoveData(removableFilesTable);
+ }
+ }
+}