mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix for Update.esm getting deleted during installation
This commit is contained in:
parent
aa2c81eb48
commit
bac8900df7
@ -353,14 +353,12 @@ namespace Wabbajack.Common
|
||||
return CreateHardLink((string)destination, (string)this, IntPtr.Zero);
|
||||
}
|
||||
|
||||
public static long HARDLINK_THRESHOLD = 2 ^ 29; // 512 MB
|
||||
|
||||
public async ValueTask HardLinkIfOversize(AbsolutePath destination)
|
||||
{
|
||||
if (!destination.Parent.Exists)
|
||||
destination.Parent.CreateDirectory();
|
||||
|
||||
if (Root == destination.Root && Size >= HARDLINK_THRESHOLD)
|
||||
if (Root == destination.Root && Consts.SupportedBSAs.Contains(Extension))
|
||||
{
|
||||
if (HardLinkTo(destination))
|
||||
return;
|
||||
|
@ -141,7 +141,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
Status($"Copying files for {archive.Name}");
|
||||
|
||||
async ValueTask CopyFile(VirtualFile? vf, AbsolutePath from, AbsolutePath to, bool useMove)
|
||||
async ValueTask CopyFile(AbsolutePath from, AbsolutePath to)
|
||||
{
|
||||
if (to.Exists)
|
||||
{
|
||||
@ -156,16 +156,7 @@ namespace Wabbajack.Lib
|
||||
from.IsReadOnly = false;
|
||||
}
|
||||
|
||||
if (vf!.IsNative)
|
||||
{
|
||||
await from.HardLinkIfOversize(to);
|
||||
return;
|
||||
}
|
||||
|
||||
if (useMove)
|
||||
await @from.MoveToAsync(to);
|
||||
else
|
||||
await @from.CopyToAsync(to);
|
||||
await @from.CopyToAsync(to);
|
||||
// If we don't do this, the file will use the last-modified date of the file when it was compressed
|
||||
// into an archive, which isn't really what we want in the case of files installed archives
|
||||
to.LastModified = DateTime.Now;
|
||||
@ -181,11 +172,18 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
var firstDest = OutputFolder.Combine(group.First().To);
|
||||
|
||||
await group.Key.StagedFile.MoveTo(firstDest);
|
||||
|
||||
if (group.Key.IsNative)
|
||||
{
|
||||
await group.Key.AbsoluteName.HardLinkIfOversize(firstDest);
|
||||
}
|
||||
else
|
||||
{
|
||||
await group.Key.StagedFile.MoveTo(firstDest);
|
||||
}
|
||||
|
||||
foreach (var copy in group.Skip(1))
|
||||
{
|
||||
await CopyFile(group.Key, firstDest, OutputFolder.Combine(copy.To), false);
|
||||
await CopyFile(firstDest, OutputFolder.Combine(copy.To));
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user