mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 16:17:03 +00:00
fix(GODT-2781): try to remove stale lock file before failing in checkSingleInstance.
This commit is contained in:
@ -137,12 +137,21 @@ bool checkSingleInstance(QLockFile &lock) {
|
|||||||
if (lock.getLockInfo(&pid, &hostname, &appName)) {
|
if (lock.getLockInfo(&pid, &hostname, &appName)) {
|
||||||
details = QString("(PID : %1 - Host : %2 - App : %3)").arg(pid).arg(hostname, appName);
|
details = QString("(PID : %1 - Host : %2 - App : %3)").arg(pid).arg(hostname, appName);
|
||||||
}
|
}
|
||||||
|
if (lock.error() == QLockFile::LockFailedError) {
|
||||||
|
// This happens if a stale lock file exists and another process uses that PID.
|
||||||
|
// Try removing the stale file, which will fail if a real process is holding a
|
||||||
|
// file-level lock. A false error is more problematic than not locking properly
|
||||||
|
// on corner-case systems.
|
||||||
|
if (lock.removeStaleLockFile() && lock.tryLock()) {
|
||||||
|
app().log().info("Removed stale lock file");
|
||||||
|
app().log().info(QString("lock file created %1").arg(lock.fileName()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
app().log().error(QString("Instance already exists %1 %2").arg(lock.fileName(), details));
|
app().log().error(QString("Instance already exists %1 %2").arg(lock.fileName(), details));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
app().log().info(QString("lock file created %1").arg(lock.fileName()));
|
|
||||||
}
|
}
|
||||||
|
app().log().info(QString("lock file created %1").arg(lock.fileName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user