Fixes for sql for unicode paths in sql tables (instead of ascitables 🤦)

This commit is contained in:
Timothy Baldridge 2020-02-03 21:58:32 -07:00
parent 1b428cd03b
commit 4377f430f3
4 changed files with 20 additions and 4 deletions

View File

@ -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;

View File

@ -215,6 +215,19 @@ namespace Wabbajack.Common
File.WriteAllText(hashPath, hash);
return hash;
}
public static async Task<string> 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<string> FileHashAsync(this string file, bool nullOnIOError = false)
{

View File

@ -62,6 +62,7 @@ namespace Wabbajack.Test
});
await DownloadAndInstall(Game.SkyrimSpecialEdition, 12604, "SkyUI");
await DownloadAndInstall(Game.Fallout4, 11925, "Anti-Tank Rifle");
utils.Configure();