From 0f679618f5953f126c12058507bc05f1fbd2733b Mon Sep 17 00:00:00 2001 From: bcssov Date: Thu, 28 Jul 2022 03:58:53 +0200 Subject: [PATCH] Whops we "deadlocked" the app, ensure to release lock --- .../Mods/Exporter/SQLiteExporter.cs | 62 ++++++++++--------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/IronyModManager.IO/Mods/Exporter/SQLiteExporter.cs b/src/IronyModManager.IO/Mods/Exporter/SQLiteExporter.cs index f6f593245..6458ccae5 100644 --- a/src/IronyModManager.IO/Mods/Exporter/SQLiteExporter.cs +++ b/src/IronyModManager.IO/Mods/Exporter/SQLiteExporter.cs @@ -4,7 +4,7 @@ // Created : 08-11-2020 // // Last Modified By : Mario -// Last Modified On : 01-16-2022 +// Last Modified On : 07-28-2022 // *********************************************************************** // // Mario @@ -90,37 +90,43 @@ public SQLiteExporter(ILogger logger, bool exportBeta) public async Task ExportAsync(ModWriterParameters parameters) { var mutex = await exportLock.LockAsync(); - // Caching sucks in this ORM - DbFieldCache.Flush(); - FieldCache.Flush(); - IdentityCache.Flush(); - PrimaryCache.Flush(); - EnsureDbExists(parameters); - var version = await GetVersionAsync(parameters); - switch (version) + try { - case Version.v3: - { - var collection = await RecreateCollectionV3Async(parameters); - await SyncModsV2Async(collection, parameters); - } - break; + // Caching sucks in this ORM + DbFieldCache.Flush(); + FieldCache.Flush(); + IdentityCache.Flush(); + PrimaryCache.Flush(); + EnsureDbExists(parameters); + var version = await GetVersionAsync(parameters); + switch (version) + { + case Version.v3: + { + var collection = await RecreateCollectionV3Async(parameters); + await SyncModsV2Async(collection, parameters); + } + break; - case Version.v4: - { - var collection = await RecreateCollectionV4Async(parameters); - await SyncModsV4Async(collection, parameters); - } - break; + case Version.v4: + { + var collection = await RecreateCollectionV4Async(parameters); + await SyncModsV4Async(collection, parameters); + } + break; - default: - { - var collection = await RecreateCollectionV2Async(parameters); - await SyncModsV2Async(collection, parameters); - } - break; + default: + { + var collection = await RecreateCollectionV2Async(parameters); + await SyncModsV2Async(collection, parameters); + } + break; + } + } + finally + { + mutex.Dispose(); } - mutex.Dispose(); return true; }