From 3edf568ef7c380564e79af14e2696b206a2cb327 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Fri, 1 Jul 2022 18:01:40 -0600 Subject: [PATCH] Fix the cache up a bit, throw log the file that fails during VFS analysis --- Wabbajack.CLI/Program.cs | 2 +- .../CesiVFSCache.cs | 4 +++- Wabbajack.Services.OSIntegrated/ServiceExtensions.cs | 2 +- Wabbajack.VFS/Context.cs | 10 +++++++++- Wabbajack.VFS/FallthroughVFSCache.cs | 12 ++++++++++-- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Wabbajack.CLI/Program.cs b/Wabbajack.CLI/Program.cs index 0557510e..984925c3 100644 --- a/Wabbajack.CLI/Program.cs +++ b/Wabbajack.CLI/Program.cs @@ -77,7 +77,7 @@ internal class Program services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/Wabbajack.Networking.WabbajackClientApi/CesiVFSCache.cs b/Wabbajack.Networking.WabbajackClientApi/CesiVFSCache.cs index f6678173..0eb0840e 100644 --- a/Wabbajack.Networking.WabbajackClientApi/CesiVFSCache.cs +++ b/Wabbajack.Networking.WabbajackClientApi/CesiVFSCache.cs @@ -1,3 +1,5 @@ +using System; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -27,7 +29,7 @@ public class CesiVFSCache : IVfsCache _logger.LogInformation("Requesting CESI Information for: {Hash} - Found", hash.ToHex()); return result; } - catch (HttpException exception) + catch (Exception exception) { _logger.LogInformation("Requesting CESI Information for: {Hash} - Not Found", hash.ToHex()); return null; diff --git a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs index fc50ba65..1e3be906 100644 --- a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs +++ b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs @@ -62,7 +62,7 @@ public static class ServiceExtensions { var diskCache = options.UseLocalCache ? new VFSDiskCache(s.GetService()!.CreateFile().Path) - : new VFSDiskCache(KnownFolders.EntryPoint.Combine("GlobalVFSCache3.sqlite")); + : new VFSDiskCache(KnownFolders.WabbajackAppLocal.Combine("GlobalVFSCache3.sqlite")); var cesiCache = new CesiVFSCache(s.GetRequiredService>(), s.GetRequiredService()); return new FallthroughVFSCache(new IVfsCache[] {diskCache, cesiCache}); diff --git a/Wabbajack.VFS/Context.cs b/Wabbajack.VFS/Context.cs index fee786dd..5822947d 100644 --- a/Wabbajack.VFS/Context.cs +++ b/Wabbajack.VFS/Context.cs @@ -70,7 +70,15 @@ public class Context if (found.LastModified == f.LastModifiedUtc().AsUnixTime() && found.Size == f.Size()) return found; - return await VirtualFile.Analyze(this, null, new NativeFileStreamFactory(f), f, token, job: job); + try + { + return await VirtualFile.Analyze(this, null, new NativeFileStreamFactory(f), f, token, job: job); + } + catch (Exception ex) + { + Logger.LogError(ex, "While analyzing {File}", f); + throw; + } }).ToList(); var newIndex = await IndexRoot.Empty.Integrate(filtered.Concat(allFiles).ToList()); diff --git a/Wabbajack.VFS/FallthroughVFSCache.cs b/Wabbajack.VFS/FallthroughVFSCache.cs index 17a6f170..c711f60d 100644 --- a/Wabbajack.VFS/FallthroughVFSCache.cs +++ b/Wabbajack.VFS/FallthroughVFSCache.cs @@ -21,9 +21,17 @@ public class FallthroughVFSCache : IVfsCache foreach (var cache in _caches) { if (result == null) + { result = await cache.Get(hash, token); - else - await cache.Put(result, token); + if (result == null) continue; + foreach (var upperCache in _caches) + { + + if (upperCache != cache) + await upperCache.Put(result, token); + } + return result; + } } return result;