feat: Debug logs for trash-updater dir migration

pull/76/head
Robert Dailey 2 years ago
parent 37d52b583a
commit f5ce60589d

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Autofac" />
<PackageReference Include="CliFx" />
<PackageReference Include="FluentValidation" />
<PackageReference Include="Flurl.Http" />
<PackageReference Include="Newtonsoft.Json" />

@ -1,11 +1,12 @@
using System.IO.Abstractions;
using System.Text.RegularExpressions;
using CliFx.Infrastructure;
namespace Common.Extensions;
public static class FileSystemExtensions
{
public static void MergeDirectory(this IFileSystem fs, string targetDir, string destDir)
public static void MergeDirectory(this IFileSystem fs, string targetDir, string destDir, IConsole? console = null)
{
targetDir = fs.Path.GetFullPath(targetDir);
destDir = fs.Path.GetFullPath(destDir);
@ -21,9 +22,11 @@ public static class FileSystemExtensions
{
var newPath = Regex.Replace(file.FullName, $"^{Regex.Escape(targetDir)}", destDir);
fs.Directory.CreateDirectory(fs.Path.GetDirectoryName(newPath));
console?.Output.WriteLine($" - Moving: {file.FullName} :: TO :: {newPath}");
file.MoveTo(newPath);
}
console?.Output.WriteLine($" - Deleting: {dir.FullName}");
dir.Delete();
}
}

@ -42,5 +42,5 @@ public class MigrateTrashUpdaterAppDataDir : IMigrationStep
public bool CheckIfNeeded() => _fs.Directory.Exists(GetOldPath());
public void Execute(IConsole? console) => _fs.MergeDirectory(GetOldPath(), GetNewPath());
public void Execute(IConsole? console) => _fs.MergeDirectory(GetOldPath(), GetNewPath(), console);
}

Loading…
Cancel
Save