From b365ec6322ccfdcd4c94262c416df526d43fb196 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sun, 1 Nov 2020 06:55:17 +1100 Subject: [PATCH] Cleanup dryrun shm and wal files if they exist (#1121) * Cleanup dryrun shm and wal files if they exist --- src/main.d | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main.d b/src/main.d index fbe815a8..df6fb637 100644 --- a/src/main.d +++ b/src/main.d @@ -380,12 +380,23 @@ int main(string[] args) // dry-run notification and database setup if (cfg.getValueBool("dry_run")) { log.log("DRY-RUN Configured. Output below shows what 'would' have occurred."); + string dryRunShmFile = cfg.databaseFilePathDryRun ~ "-shm"; + string dryRunWalFile = cfg.databaseFilePathDryRun ~ "-wal"; // If the dry run database exists, clean this up if (exists(cfg.databaseFilePathDryRun)) { // remove the existing file log.vdebug("Removing items-dryrun.sqlite3 as it still exists for some reason"); safeRemove(cfg.databaseFilePathDryRun); } + // silent cleanup of shm and wal files if they exist + if (exists(dryRunShmFile)) { + // remove items-dryrun.sqlite3-shm + safeRemove(dryRunShmFile); + } + if (exists(dryRunWalFile)) { + // remove items-dryrun.sqlite3-wal + safeRemove(dryRunWalFile); + } // Make a copy of the original items.sqlite3 for use as the dry run copy if it exists if (exists(cfg.databaseFilePath)) { @@ -1124,11 +1135,23 @@ int main(string[] args) // --dry-run temp database cleanup if (cfg.getValueBool("dry_run")) { + string dryRunShmFile = cfg.databaseFilePathDryRun ~ "-shm"; + string dryRunWalFile = cfg.databaseFilePathDryRun ~ "-wal"; if (exists(cfg.databaseFilePathDryRun)) { // remove the file log.vdebug("Removing items-dryrun.sqlite3 as dry run operations complete"); + // remove items-dryrun.sqlite3 safeRemove(cfg.databaseFilePathDryRun); } + // silent cleanup of shm and wal files if they exist + if (exists(dryRunShmFile)) { + // remove items-dryrun.sqlite3-shm + safeRemove(dryRunShmFile); + } + if (exists(dryRunWalFile)) { + // remove items-dryrun.sqlite3-wal + safeRemove(dryRunWalFile); + } } // Exit application