TestDirectMatch passes!

This commit is contained in:
Timothy Baldridge 2019-11-15 06:37:04 -07:00
parent f6a27ac094
commit bb4354ad20
2 changed files with 56 additions and 14 deletions

View File

@ -4,6 +4,7 @@ using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Wabbajack.Common;
using Wabbajack.Lib.Downloaders;
@ -149,7 +150,7 @@ namespace Wabbajack.Lib
Error("Cannot continue, was unable to download one or more archives");
}
PrimeVFS();
PrimeVFS().Wait();
BuildFolderStructure();
InstallArchives();
@ -232,7 +233,7 @@ namespace Wabbajack.Lib
/// We don't want to make the installer index all the archives, that's just a waste of time, so instead
/// we'll pass just enough information to VFS to let it know about the files we have.
/// </summary>
private void PrimeVFS()
private async Task PrimeVFS()
{
VFS.AddKnown(HashedArchives.Select(a => new KnownFile
{
@ -240,18 +241,13 @@ namespace Wabbajack.Lib
Hash = a.Key
}));
VFS.AddKnown(
ModList.Directives
.OfType<FromArchive>()
.Select(f =>
{
var updated_path = new string[f.ArchiveHashPath.Length];
f.ArchiveHashPath.CopyTo(updated_path, 0);
updated_path[0] = VFS.Index.ByHash[updated_path[0]].First(e => e.IsNative).FullPath;
return new KnownFile { Paths = updated_path};
});
.Select(f => new KnownFile { Paths = f.ArchiveHashPath}));
VFS.BackfillMissing();
await VFS.BackfillMissing();
}
private void BuildBSAs()

View File

@ -205,15 +205,60 @@ namespace Wabbajack.VirtualFileSystem
return new DisposableList<VirtualFile>(await Stage(files), files);
}
#region KnownFiles
private List<KnownFile> _knownFiles = new List<KnownFile>();
public void AddKnown(IEnumerable<KnownFile> known)
{
throw new NotImplementedException();
_knownFiles.AddRange(known);
}
public void BackfillMissing()
public async Task BackfillMissing()
{
throw new NotImplementedException();
var newFiles = _knownFiles.Where(f => f.Paths.Length == 1)
.GroupBy(f => f.Hash)
.ToDictionary(f => f.Key, s => new VirtualFile()
{
Name = s.First().Paths[0],
Hash = s.First().Hash,
Context = this
});
var parentchild = new Dictionary<(VirtualFile, string), VirtualFile>();
void BackFillOne(KnownFile file)
{
var parent = newFiles[file.Paths[0]];
foreach (var path in file.Paths.Skip(1))
{
if (parentchild.TryGetValue((parent, path), out var foundParent))
{
parent = foundParent;
continue;
}
var nf = new VirtualFile();
nf.Name = path;
nf.Parent = parent;
parent.Children = parent.Children.Add(nf);
parentchild.Add((parent, path), nf);
parent = nf;
}
}
_knownFiles.Where(f => f.Paths.Length > 1).Do(BackFillOne);
var newIndex = await Index.Integrate(newFiles.Values.ToList());
lock (this)
Index = newIndex;
_knownFiles = new List<KnownFile>();
}
#endregion
}
public class KnownFile
@ -280,6 +325,7 @@ namespace Wabbajack.VirtualFileSystem
var byHash = Task.Run(() =>
allFiles.SelectMany(f => f.ThisAndAllChildren)
.Where(f => f.Hash != null)
.ToGroupedImmutableDictionary(f => f.Hash));
var byName = Task.Run(() =>