diff --git a/VirtualFileSystem/VirtualFileSystem.cs b/VirtualFileSystem/VirtualFileSystem.cs index ec4ee82a..f54f9931 100644 --- a/VirtualFileSystem/VirtualFileSystem.cs +++ b/VirtualFileSystem/VirtualFileSystem.cs @@ -68,12 +68,9 @@ namespace VFS public IList FilesInArchive(VirtualFile f) { var path = f.FullPath + "|"; - lock (this) - { - return _files.Values - .Where(v => v.FullPath.StartsWith(path)) - .ToList(); - } + return _files.Values + .Where(v => v.FullPath.StartsWith(path)) + .ToList(); } @@ -358,8 +355,21 @@ namespace VFS [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public class VirtualFile { + public string[] _paths; [JsonProperty] - public string[] Paths { get; set; } + public string[] Paths + { + get + { + return _paths; + } + set + { + for (int idx = 0; idx < value.Length; idx += 1) + value[idx] = String.Intern(value[idx]); + _paths = value; + } + } [JsonProperty] public string Hash { get; set; } [JsonProperty] diff --git a/Wabbajack/AppState.cs b/Wabbajack/AppState.cs index 9ccd4769..347a8519 100644 --- a/Wabbajack/AppState.cs +++ b/Wabbajack/AppState.cs @@ -130,6 +130,7 @@ namespace Wabbajack public AppState(Dispatcher d, String mode) { + _startTime = DateTime.Now; ArchiveFile.SetupLibrary(); LogFile = Assembly.GetExecutingAssembly().Location + ".log"; @@ -186,6 +187,7 @@ namespace Wabbajack public void LogMsg(string msg) { + msg = $"{(DateTime.Now - _startTime).TotalSeconds:0.##} - {msg}"; dispatcher.Invoke(() => Log.Add(msg)); lock (dispatcher) { File.AppendAllText(LogFile, msg + "\r\n"); @@ -264,6 +266,8 @@ namespace Wabbajack } private ICommand _begin; + private DateTime _startTime; + public ICommand Begin { get diff --git a/Wabbajack/Compiler.cs b/Wabbajack/Compiler.cs index 78cf118d..2851d74a 100644 --- a/Wabbajack/Compiler.cs +++ b/Wabbajack/Compiler.cs @@ -137,17 +137,21 @@ namespace Wabbajack public void Compile() { + Info($"Indexing {MO2Folder}"); VFS.AddRoot(MO2Folder); + Info($"Indexing {GamePath}"); VFS.AddRoot(GamePath); var mo2_files = Directory.EnumerateFiles(MO2Folder, "*", SearchOption.AllDirectories) .Where(p => p.FileExists()) - .Select(p => new RawSourceFile(VFS.Lookup(p))); + .Select(p => new RawSourceFile(VFS.Lookup(p)) { Path = p.RelativeTo(MO2Folder)}); var game_files = Directory.EnumerateFiles(GamePath, "*", SearchOption.AllDirectories) .Where(p => p.FileExists()) .Select(p => new RawSourceFile(VFS.Lookup(p)) { Path = Path.Combine(Consts.GameFolderFilesDir, p.RelativeTo(GamePath))}); + + Info($"Indexing Archives"); IndexedArchives = Directory.EnumerateFiles(MO2DownloadsFolder) .Where(f => Consts.SupportedArchives.Contains(Path.GetExtension(f))) .Where(f => File.Exists(f + ".meta")) @@ -159,7 +163,10 @@ namespace Wabbajack }) .ToList(); - IndexedFiles = IndexedArchives.SelectMany(f => VFS.FilesInArchive(f.File)) + Info($"Indexing Files"); + IndexedFiles = IndexedArchives.PMap(f => { Status($"Finding files in {Path.GetFileName(f.File.FullPath)}"); + return VFS.FilesInArchive(f.File); }) + .SelectMany(fs => fs) .OrderByDescending(f => f.TopLevelArchive.LastModified) .GroupBy(f => f.Hash) .ToDictionary(f => f.Key, f => f.AsEnumerable());