From 986dbd678f97c4fab54af4b7ccbeea3e71423e07 Mon Sep 17 00:00:00 2001 From: MBucari Date: Wed, 3 Dec 2025 22:09:35 -0700 Subject: [PATCH] Don't throw exceptions from failure to delete db-wal and db-shm files (#1478) --- Source/AppScaffolding/LibationScaffolding.cs | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Source/AppScaffolding/LibationScaffolding.cs b/Source/AppScaffolding/LibationScaffolding.cs index b6ee8b1e..159d6e4a 100644 --- a/Source/AppScaffolding/LibationScaffolding.cs +++ b/Source/AppScaffolding/LibationScaffolding.cs @@ -105,15 +105,35 @@ namespace AppScaffolding /// /// Delete shared memory and write-ahead log SQLite database files which may prevent access to the database. + /// These file may or may not cause libation to hang on CreateContext, + /// so try our luck by swallowing any exceptions and continuing. /// private static void DeleteOpenSqliteFiles(Configuration config) { var walFile = SqliteStorage.DatabasePath + "-wal"; var shmFile = SqliteStorage.DatabasePath + "-shm"; if (File.Exists(walFile)) - FileManager.FileUtility.SaferDelete(walFile); + { + try + { + FileManager.FileUtility.SaferDelete(walFile); + } + catch(Exception ex) + { + Log.Logger.Warning(ex, "Could not delete SQLite WAL file: {@WalFile}", walFile); + } + } if (File.Exists(shmFile)) - FileManager.FileUtility.SaferDelete(shmFile); + { + try + { + FileManager.FileUtility.SaferDelete(shmFile); + } + catch (Exception ex) + { + Log.Logger.Warning(ex, "Could not delete SQLite SHM file: {@ShmFile}", shmFile); + } + } } /// Initialize logging. Wire-up events. Run after migration