diff --git a/Wabbajack.BuildServer/Models/Jobs/ReindexArchives.cs b/Wabbajack.BuildServer/Models/Jobs/ReindexArchives.cs index 678b22ed..c04befa6 100644 --- a/Wabbajack.BuildServer/Models/Jobs/ReindexArchives.cs +++ b/Wabbajack.BuildServer/Models/Jobs/ReindexArchives.cs @@ -18,18 +18,20 @@ namespace Wabbajack.BuildServer.Models.Jobs { using (var queue = new WorkQueue()) { - var total_count = Directory.EnumerateFiles(settings.ArchiveDir).Count(); + var files = Directory.EnumerateFiles(settings.ArchiveDir) + .Where(f => !f.EndsWith(Consts.HashFileExtension)) + .ToList(); + var total_count = files.Count; int completed = 0; - await Directory.EnumerateFiles(settings.ArchiveDir) - .PMap(queue, async file => + await files.PMap(queue, async file => { try { Interlocked.Increment(ref completed); - if (await sql.HaveIndexdFile(await file.FileHashAsync())) + if (await sql.HaveIndexdFile(await file.FileHashCachedAsync())) { Utils.Log($"({completed}/{total_count}) Skipping {Path.GetFileName(file)}, it's already indexed"); return; diff --git a/Wabbajack.BuildServer/sql/wabbajack_db.sql b/Wabbajack.BuildServer/sql/wabbajack_db.sql index 64c514d5..cc1e84f0 100644 Binary files a/Wabbajack.BuildServer/sql/wabbajack_db.sql and b/Wabbajack.BuildServer/sql/wabbajack_db.sql differ diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 7c1c0c02..decdf315 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -215,6 +215,19 @@ namespace Wabbajack.Common File.WriteAllText(hashPath, hash); return hash; } + + public static async Task FileHashCachedAsync(this string file, bool nullOnIOError = false) + { + var hashPath = file + Consts.HashFileExtension; + if (File.Exists(hashPath) && File.GetLastWriteTime(file) <= File.GetLastWriteTime(hashPath)) + { + return File.ReadAllText(hashPath); + } + + var hash = await file.FileHashAsync(nullOnIOError); + File.WriteAllText(hashPath, hash); + return hash; + } public static async Task FileHashAsync(this string file, bool nullOnIOError = false) { diff --git a/Wabbajack.Test/EndToEndTests.cs b/Wabbajack.Test/EndToEndTests.cs index f7717658..e98687f1 100644 --- a/Wabbajack.Test/EndToEndTests.cs +++ b/Wabbajack.Test/EndToEndTests.cs @@ -62,6 +62,7 @@ namespace Wabbajack.Test }); await DownloadAndInstall(Game.SkyrimSpecialEdition, 12604, "SkyUI"); + await DownloadAndInstall(Game.Fallout4, 11925, "Anti-Tank Rifle"); utils.Configure();