mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-10 17:56:44 +02:00
Improve application runtime check (#1955)
* Improve application runtime check fixing false positive when CTRL-C is used to terminate application
This commit is contained in:
parent
04c65f9b48
commit
7139578af1
12
src/itemdb.d
12
src/itemdb.d
|
@ -51,7 +51,13 @@ final class ItemDatabase
|
|||
dbVersion = db.getVersion();
|
||||
} catch (SqliteException e) {
|
||||
// An error was generated - what was the error?
|
||||
log.error("\nAn internal database error occurred: " ~ e.msg ~ "\n");
|
||||
if (e.msg == "database is locked") {
|
||||
log.error("\nERROR: 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");
|
||||
write("\n");
|
||||
} else {
|
||||
log.error("\nERROR: An internal database error occurred: " ~ e.msg ~ "\n");
|
||||
}
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -84,6 +90,10 @@ final class ItemDatabase
|
|||
// https://www.sqlite.org/pragma.html#pragma_auto_vacuum
|
||||
// PRAGMA schema.auto_vacuum = 0 | NONE | 1 | FULL | 2 | INCREMENTAL;
|
||||
db.exec("PRAGMA auto_vacuum = FULL");
|
||||
// This pragma sets or queries the database connection locking-mode. The locking-mode is either NORMAL or EXCLUSIVE.
|
||||
// https://www.sqlite.org/pragma.html#pragma_locking_mode
|
||||
// PRAGMA schema.locking_mode = NORMAL | EXCLUSIVE
|
||||
db.exec("PRAGMA locking_mode = EXCLUSIVE");
|
||||
|
||||
insertItemStmt = "
|
||||
INSERT OR REPLACE INTO item (driveId, id, name, type, eTag, cTag, mtime, parentId, crc32Hash, sha1Hash, quickXorHash, remoteDriveId, remoteId, syncStatus)
|
||||
|
|
11
src/main.d
11
src/main.d
|
@ -163,17 +163,6 @@ 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")) && (!cfg.getValueBool("display_config"))) {
|
||||
// what is the risk acceptance?
|
||||
|
|
Loading…
Reference in a new issue