Skip to content

Commit

Permalink
Fix Unable to perform a database vacuum: out of memory when exiting (#…
Browse files Browse the repository at this point in the history
…2398)

* Due to many poor Internet sources of how to use this application, may folk still do not add --synchronize or --monitor switches because their documentation source fails to detail this. When this is the case, the itemdb does not get fully initialised, but when we exit, we try and clean up, because we have partially initalised, we cannot perform a vacuum of the database which generates an error. This patch adds a flag for this specific scenario, so that if triggered, we do not try to vacuum the database and not triggering a false error.
  • Loading branch information
abraunegg authored May 12, 2023
1 parent d960feb commit 16b7519
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ int main(string[] args)
bool displaySyncOptions = false;
bool cleanupLocalFilesGlobal = false;
bool synchronizeConfigured = false;
bool invalidSyncExit = false;

// start and finish messages
string startMessage = "Starting a sync with OneDrive";
Expand Down Expand Up @@ -85,7 +86,9 @@ int main(string[] args)
// was itemDb initialised?
if (itemDb !is null) {
// Make sure the .wal file is incorporated into the main db before we exit
itemDb.performVacuum();
if(!invalidSyncExit) {
itemDb.performVacuum();
}
destroy(itemDb);
}
// cleanup any dry-run data
Expand Down Expand Up @@ -116,7 +119,9 @@ int main(string[] args)
// was itemDb initialised?
if (itemDb !is null) {
// Make sure the .wal file is incorporated into the main db before we exit
itemDb.performVacuum();
if(!invalidSyncExit) {
itemDb.performVacuum();
}
destroy(itemDb);
}
// cleanup any dry-run data
Expand Down Expand Up @@ -985,6 +990,7 @@ int main(string[] args)
log.log("\n--synchronize or --monitor switches missing from your command line input. Please add one (not both) of these switches to your command line or use 'onedrive --help' for further assistance.\n");
log.log("No OneDrive sync will be performed without one of these two arguments being present.\n");
// Use exit scopes to shutdown API
invalidSyncExit = true;
return EXIT_FAILURE;
}
}
Expand Down

0 comments on commit 16b7519

Please sign in to comment.