From 287eebdd3d56bfee4761b755f2316cd6d49ae0c5 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Mon, 4 May 2020 14:39:43 -0600 Subject: [PATCH] Fix tests and implement hard link support --- Wabbajack.Common/Paths.cs | 13 +++++-------- Wabbajack.Lib/Tasks/MigrateGameFolder.cs | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Wabbajack.Common/Paths.cs b/Wabbajack.Common/Paths.cs index e892b47c..e006d552 100644 --- a/Wabbajack.Common/Paths.cs +++ b/Wabbajack.Common/Paths.cs @@ -349,6 +349,7 @@ namespace Wabbajack.Common public bool HardLinkTo(AbsolutePath destination) { + Utils.Log($"Hard Linking {_path} to {destination}"); return CreateHardLink((string)destination, (string)this, IntPtr.Zero); } @@ -356,7 +357,10 @@ namespace Wabbajack.Common public async ValueTask HardLinkIfOversize(AbsolutePath destination) { - if (Root == destination.Root || Size >= HARDLINK_THRESHOLD) + if (!destination.Parent.Exists) + destination.Parent.CreateDirectory(); + + if (Root == destination.Root && Size >= HARDLINK_THRESHOLD) { if (HardLinkTo(destination)) return; @@ -432,13 +436,6 @@ namespace Wabbajack.Common await file.CopyToAsync(dest); } } - - public async Task CopyOrLinkIfOverSizeAsync(AbsolutePath newFile) - { - if (newFile.Parent != default) - newFile.Parent.CreateDirectory(); - await CopyToAsync(newFile); - } } [JsonConverter(typeof(Utils.RelativePathConverter))] diff --git a/Wabbajack.Lib/Tasks/MigrateGameFolder.cs b/Wabbajack.Lib/Tasks/MigrateGameFolder.cs index 10905607..06feb725 100644 --- a/Wabbajack.Lib/Tasks/MigrateGameFolder.cs +++ b/Wabbajack.Lib/Tasks/MigrateGameFolder.cs @@ -37,7 +37,7 @@ namespace Wabbajack.Lib.Tasks } Utils.Log($"Copying/Linking {relPath}"); - await file.CopyOrLinkIfOverSizeAsync(newFile); + await file.HardLinkIfOversize(newFile); } Utils.Log("Remapping INI");