Fix tests and implement hard link support

This commit is contained in:
Timothy Baldridge 2020-05-04 14:39:43 -06:00
parent 314c77a830
commit 287eebdd3d
2 changed files with 6 additions and 9 deletions

View File

@ -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))]

View File

@ -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");