From 716e092fd0df6631496200820e3562bda27b16ff Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 23 Sep 2024 18:18:38 +0000 Subject: [PATCH] fix: Fixed claimed waifu decay that was introduced in a recent patch dev: Cleaned up a little bit in medusa loading. Clean medusa unloading will be broken for a while probably --- .../Modules/Gambling/Waifus/WaifuService.cs | 2 +- .../Medusa/Common/MedusaLoaderService.cs | 40 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/NadekoBot/Modules/Gambling/Waifus/WaifuService.cs b/src/NadekoBot/Modules/Gambling/Waifus/WaifuService.cs index 83c8c4d0a..56feeb5d0 100644 --- a/src/NadekoBot/Modules/Gambling/Waifus/WaifuService.cs +++ b/src/NadekoBot/Modules/Gambling/Waifus/WaifuService.cs @@ -577,7 +577,7 @@ public class WaifuService : INService, 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/NadekoBot/_common/Medusa/Common/MedusaLoaderService.cs b/src/NadekoBot/_common/Medusa/Common/MedusaLoaderService.cs index 95f505b9a..7b7a88afd 100644 --- a/src/NadekoBot/_common/Medusa/Common/MedusaLoaderService.cs +++ b/src/NadekoBot/_common/Medusa/Common/MedusaLoaderService.cs @@ -250,6 +250,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor, } catch (Exception ex) when (ex is FileNotFoundException or BadImageFormatException) { + Log.Error(ex, "An error occurred loading a medusa"); return MedusaLoadResult.NotFound; } catch (Exception ex) @@ -334,23 +335,34 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor, var a = ctx.LoadFromAssemblyPath(Path.GetFullPath(path)); // ctx.LoadDependencies(a); + iocModule = null; // load services - iocModule = new MedusaNinjectIocModule(_cont, a, safeName); - iocModule.Load(); - - var sis = LoadSneksFromAssembly(safeName, a); - typeReaders = LoadTypeReadersFromAssembly(a, strings); - - if (sis.Count == 0) + try { - iocModule.Unload(); - return false; + iocModule = new MedusaNinjectIocModule(_cont, a, safeName); + iocModule.Load(); + + var sis = LoadSneksFromAssembly(safeName, a); + typeReaders = LoadTypeReadersFromAssembly(a, strings); + + if (sis.Count == 0) + { + iocModule.Unload(); + ctx.Unload(); + return false; + } + + ctxWr = new(ctx); + snekData = sis; + + return true; + } + catch + { + iocModule?.Unload(); + ctx.Unload(); + throw; } - - ctxWr = new(ctx); - snekData = sis; - - return true; } private static readonly Type _paramParserType = typeof(ParamParser<>);