mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Move files into the install folder instead of copying them, should drastically reduce IO during installation.
This commit is contained in:
parent
3f4a2bb733
commit
9d609fb0ca
@ -410,13 +410,29 @@ namespace Wabbajack.Lib
|
||||
|
||||
Status($"Copying files for {archive.Name}");
|
||||
|
||||
vfiles.DoIndexed((idx, file) =>
|
||||
void CopyFile(string from, string to, bool use_move)
|
||||
{
|
||||
if (File.Exists(to))
|
||||
File.Delete(to);
|
||||
if (use_move)
|
||||
File.Move(from, to);
|
||||
else
|
||||
File.Copy(from, to);
|
||||
}
|
||||
|
||||
vfiles.GroupBy(f => f.FromFile)
|
||||
.DoIndexed((idx, group) =>
|
||||
{
|
||||
Utils.Status("Installing files", idx * 100 / vfiles.Count);
|
||||
var dest = Path.Combine(Outputfolder, file.To);
|
||||
if (File.Exists(dest))
|
||||
File.Delete(dest);
|
||||
File.Copy(file.FromFile.StagedPath, dest);
|
||||
var first_dest = Path.Combine(Outputfolder, group.First().To);
|
||||
CopyFile(group.Key.StagedPath, first_dest, true);
|
||||
|
||||
foreach (var copy in group.Skip(1))
|
||||
{
|
||||
var next_dest = Path.Combine(Outputfolder, copy.To);
|
||||
CopyFile(first_dest, next_dest, false);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Status("Unstaging files");
|
||||
|
@ -34,6 +34,29 @@ namespace Wabbajack.Test
|
||||
utils.VerifyInstalledFile(mod, @"Data\scripts\test.pex");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestDuplicateFilesAreCopied()
|
||||
{
|
||||
|
||||
var profile = utils.AddProfile();
|
||||
var mod = utils.AddMod();
|
||||
var test_pex = utils.AddModFile(mod, @"Data\scripts\test.pex", 10);
|
||||
|
||||
// Make a copy to make sure it gets picked up and moved around.
|
||||
File.Copy(test_pex, test_pex + ".copy");
|
||||
|
||||
utils.Configure();
|
||||
|
||||
utils.AddManualDownload(
|
||||
new Dictionary<string, byte[]> { { "/baz/biz.pex", File.ReadAllBytes(test_pex) } });
|
||||
|
||||
CompileAndInstall(profile);
|
||||
|
||||
utils.VerifyInstalledFile(mod, @"Data\scripts\test.pex");
|
||||
utils.VerifyInstalledFile(mod, @"Data\scripts\test.pex.copy");
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void CleanedESMTest()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user