Detect if application is already operational (#1944)

* In some scenarios users may have a running background service syncing data (systemd or otherwise). In these events, running the application in standalone mode can create a conflict when attempting to perform database queries when there are significant changes to data structures occurring. This PR specifically checks if the database operation files are present, and, if these are present (meaning the application is most likely currently operational) fail fast and not execute the application as a second instance against the same active configuration.

Potentially also resolves RBZ2061430 and RBZ2075468
This commit is contained in:
abraunegg 2022-05-03 15:09:08 +10:00 committed by GitHub
parent 10448efd9a
commit 5506efb313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -162,6 +162,17 @@ int main(string[] args)
// update configuration from command line args
cfg.update_from_args(args);
// In some cases, a user may have a systemd service running, and, also attempt a manual sync
// This causes issues with DB items / DB entries if there are significant changes in the database
// Check to see if 'items.sqlite3-shm' and 'items.sqlite3-wal' are present - if they are present, we need to exit early
string activeShmFile = cfg.databaseFilePath ~ "-shm";
string activeWalFile = cfg.databaseFilePath ~ "-wal";
if (exists(asNormalizedPath(activeShmFile)) || exists(asNormalizedPath(activeWalFile))) {
log.error("ERROR: onedrive application is already running - check system process list for active application instances");
log.vlog(" - Use 'sudo ps aufxw | grep onedrive' to potentially determine acive running process");
return EXIT_FAILURE;
}
// --resync should be a 'last resort item' .. the user needs to 'accept' to proceed
if (cfg.getValueBool("resync")) {