From 4afa604a1b83f29a9b7d55aecfe6dd7a48c2d945 Mon Sep 17 00:00:00 2001 From: Toastie Date: Tue, 24 Sep 2024 20:48:49 +1200 Subject: [PATCH] Fixed claimed waifu decay that was introduced in a recent patch. Cleaned up a little bit in marmalade loading. Clean marmalade unloading will be broken for a while probably --- .../Modules/Gambling/Waifus/WaifuService.cs | 2 +- .../Common/MarmaladeLoaderService.cs | 40 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/EllieBot/Modules/Gambling/Waifus/WaifuService.cs b/src/EllieBot/Modules/Gambling/Waifus/WaifuService.cs index 286d9e8..5a00ab5 100644 --- a/src/EllieBot/Modules/Gambling/Waifus/WaifuService.cs +++ b/src/EllieBot/Modules/Gambling/Waifus/WaifuService.cs @@ -577,7 +577,7 @@ public class WaifuService : IEService, IReadyExecutor { await using var uow = _db.GetDbContext(); await uow.GetTable() - .Where(x => x.Price > minPrice && x.ClaimerId == null) + .Where(x => x.Price > minPrice && x.ClaimerId != null) .UpdateAsync(old => new() { Price = (long)(old.Price * claimedMulti) diff --git a/src/EllieBot/_common/Marmalade/Common/MarmaladeLoaderService.cs b/src/EllieBot/_common/Marmalade/Common/MarmaladeLoaderService.cs index 1c6dd00..06bebb5 100644 --- a/src/EllieBot/_common/Marmalade/Common/MarmaladeLoaderService.cs +++ b/src/EllieBot/_common/Marmalade/Common/MarmaladeLoaderService.cs @@ -250,6 +250,7 @@ public sealed class MarmaladeLoaderService : IMarmaladeLoaderService, IReadyExec } catch (Exception ex) when (ex is FileNotFoundException or BadImageFormatException) { + Log.Error(ex, "An error occurred loading a marmalade"); return MarmaladeLoadResult.NotFound; } catch (Exception ex) @@ -334,23 +335,34 @@ public sealed class MarmaladeLoaderService : IMarmaladeLoaderService, IReadyExec var a = ctx.LoadFromAssemblyPath(Path.GetFullPath(path)); // ctx.LoadDependencies(a); + iocModule = null; // load services - iocModule = new MarmaladeNinjectIocModule(_cont, a, safeName); - iocModule.Load(); - - var sis = LoadCanariesFromAssembly(safeName, a); - typeReaders = LoadTypeReadersFromAssembly(a, strings); - - if (sis.Count == 0) + try { - iocModule.Unload(); - return false; + iocModule = new MarmaladeNinjectIocModule(_cont, a, safeName); + iocModule.Load(); + + var sis = LoadCanariesFromAssembly(safeName, a); + typeReaders = LoadTypeReadersFromAssembly(a, strings); + + if (sis.Count == 0) + { + iocModule.Unload(); + ctx.Unload(); + return false; + } + + ctxWr = new(ctx); + canaryData = sis; + + return true; + } + catch + { + iocModule?.Unload(); + ctx.Unload(); + throw; } - - ctxWr = new(ctx); - canaryData = sis; - - return true; } private static readonly Type _paramParserType = typeof(ParamParser<>);