From b91e7348b7f2d6637261efe5bd5dc8976e19525b Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Tue, 20 Aug 2019 16:37:55 -0600 Subject: [PATCH] Can install Basic Fixes.exe with the new VFS backend --- VirtualFileSystem/VirtualFileSystem.cs | 16 +++++++++++++++- Wabbajack/Installer.cs | 13 ++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/VirtualFileSystem/VirtualFileSystem.cs b/VirtualFileSystem/VirtualFileSystem.cs index 8a3532a4..477bdadf 100644 --- a/VirtualFileSystem/VirtualFileSystem.cs +++ b/VirtualFileSystem/VirtualFileSystem.cs @@ -140,6 +140,7 @@ namespace VFS { _files.Values .Select(f => f.ParentPath) + .Where(s => s != null) .Where(s => !_files.ContainsKey(s)) .ToHashSet() .Do(s => @@ -252,7 +253,10 @@ namespace VFS public void Stage(IEnumerable files) { - var grouped = files.GroupBy(f => f.ParentArchive) + var grouped = files.SelectMany(f => f.FilesInPath) + .Distinct() + .Where(f => f.ParentArchive != null) + .GroupBy(f => f.ParentArchive) .OrderBy(f => f.Key == null ? 0 : f.Key.Paths.Length) .ToList(); @@ -565,6 +569,16 @@ namespace VFS path_copy[0] = VirtualFileSystem.VFS.Lookup(Paths[0]).Hash; return path_copy; } + + public IEnumerable FilesInPath + { + get { + return Enumerable.Range(1, Paths.Length) + .Select(i => Paths.Take(i)) + .Select(path => VirtualFileSystem.VFS.Lookup(String.Join("|", path))); + + } + } } diff --git a/Wabbajack/Installer.cs b/Wabbajack/Installer.cs index c0cb6f62..73952e8a 100644 --- a/Wabbajack/Installer.cs +++ b/Wabbajack/Installer.cs @@ -117,8 +117,8 @@ namespace Wabbajack { HashedArchives.Do(a => VFS.AddKnown(new VirtualFile() { - Paths = new string[] { a.Key }, - Hash = a.Value + Paths = new string[] { a.Value }, + Hash = a.Key })); VFS.RefreshIndexes(); @@ -127,7 +127,7 @@ namespace Wabbajack .OfType() .Do(f => { - var updated_path = new string[f.ArchiveHashPath.Length + 1]; + var updated_path = new string[f.ArchiveHashPath.Length]; f.ArchiveHashPath.CopyTo(updated_path, 0); updated_path[0] = VFS.HashIndex[updated_path[0]].Where(e => e.IsConcrete).First().FullPath; VFS.AddKnown(new VirtualFile() { Paths = updated_path }); @@ -174,8 +174,11 @@ namespace Wabbajack } }); - Info($"Removing temp folder {Consts.BSACreationDir}"); - Directory.Delete(Path.Combine(Outputfolder, Consts.BSACreationDir), true); + if (Directory.Exists(Consts.BSACreationDir)) + { + Info($"Removing temp folder {Consts.BSACreationDir}"); + Directory.Delete(Path.Combine(Outputfolder, Consts.BSACreationDir), true); + } }