mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #154 from wabbajack-tools/move-dont-copy
Move files into the install folder
This commit is contained in:
@ -397,13 +397,29 @@ namespace Wabbajack.Lib
|
|||||||
|
|
||||||
Status($"Copying files for {archive.Name}");
|
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);
|
Utils.Status("Installing files", idx * 100 / vfiles.Count);
|
||||||
var dest = Path.Combine(Outputfolder, file.To);
|
var first_dest = Path.Combine(Outputfolder, group.First().To);
|
||||||
if (File.Exists(dest))
|
CopyFile(group.Key.StagedPath, first_dest, true);
|
||||||
File.Delete(dest);
|
|
||||||
File.Copy(file.FromFile.StagedPath, dest);
|
foreach (var copy in group.Skip(1))
|
||||||
|
{
|
||||||
|
var next_dest = Path.Combine(Outputfolder, copy.To);
|
||||||
|
CopyFile(first_dest, next_dest, false);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Status("Unstaging files");
|
Status("Unstaging files");
|
||||||
|
@ -34,6 +34,29 @@ namespace Wabbajack.Test
|
|||||||
utils.VerifyInstalledFile(mod, @"Data\scripts\test.pex");
|
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]
|
[TestMethod]
|
||||||
public void CleanedESMTest()
|
public void CleanedESMTest()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user