Fix the cache up a bit, throw log the file that fails during VFS analysis

This commit is contained in:
Timothy Baldridge 2022-07-01 18:01:40 -06:00
parent 1c0fec2d02
commit 3edf568ef7
5 changed files with 24 additions and 6 deletions

View File

@ -77,7 +77,7 @@ internal class Program
services.AddSingleton<IVerb, DumpZipInfo>();
services.AddSingleton<IVerb, Install>();
services.AddSingleton<IVerb, InstallCompileInstallVerify>();
services.AddSingleton<IVerb, HashUrlString>();
services.AddSingleton<IVerb, HashUrlString>();
services.AddSingleton<IVerb, DownloadAll>();
services.AddSingleton<IUserInterventionHandler, UserInterventionHandler>();

View File

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

View File

@ -62,7 +62,7 @@ public static class ServiceExtensions
{
var diskCache = options.UseLocalCache
? new VFSDiskCache(s.GetService<TemporaryFileManager>()!.CreateFile().Path)
: new VFSDiskCache(KnownFolders.EntryPoint.Combine("GlobalVFSCache3.sqlite"));
: new VFSDiskCache(KnownFolders.WabbajackAppLocal.Combine("GlobalVFSCache3.sqlite"));
var cesiCache = new CesiVFSCache(s.GetRequiredService<ILogger<CesiVFSCache>>(),
s.GetRequiredService<Client>());
return new FallthroughVFSCache(new IVfsCache[] {diskCache, cesiCache});

View File

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

View File

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