summaryrefslogtreecommitdiffstats
path: root/src/sdk/installerbase.cpp
diff options
context:
space:
mode:
authorFrerich Raabe <raabe@froglogic.com>2016-06-02 11:40:47 +0200
committerKatja Marttila <katja.marttila@qt.io>2016-06-15 08:54:46 +0000
commitb4a1a89e306367feaec56ce9902d15234ece5f84 (patch)
tree5807e51d2b77c4df676136444726f2a003bd3c6a /src/sdk/installerbase.cpp
parentf11fce311bb954457da1641ccbc6684e7cdd3418 (diff)
Store lock files in temporary directory
The directory in which the application is stored may not be writable for the current user, e.g. if the installer is stored on a read-only network drive, or (common case on OS X) if the installer bundle is started from a read-only .dmg image. This fixes warnings in the verbose output (especially noticeable during unattended installations) like: [0] Warning: Cannot create lock file "/Volumes/froglogic Squish/Install Squish.app/Contents/MacOS/Squish1234865.lock": Read-only file system The patch is defensive in that it just uses QDir::tempPath() instead of going for QTemporaryFile to avoid having to worry about auto-delete semantics. Change-Id: Iee2409dd6f884c4fe234057b2926eee82127f985 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/sdk/installerbase.cpp')
-rw-r--r--src/sdk/installerbase.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index 27402ffed..80fc7b8b3 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -55,6 +55,7 @@
#include <runoncechecker.h>
#include <filedownloaderfactory.h>
+#include <QDir>
#include <QDirIterator>
#include <QTemporaryFile>
#include <QTranslator>
@@ -75,15 +76,16 @@ InstallerBase::~InstallerBase()
int InstallerBase::run()
{
- RunOnceChecker runCheck(qApp->applicationDirPath()
+ RunOnceChecker runCheck(QDir::tempPath()
+ QLatin1Char('/')
+ qApp->applicationName()
+ QLatin1String("1234865.lock"));
if (runCheck.isRunning(RunOnceChecker::ConditionFlag::Lockfile)) {
- // It is possible to install an application and thus the maintenance tool into a
- // directory that requires elevated permission to create a lock file. Since this
- // cannot be done without requesting credentials from the user, we silently ignore
- // the fact that we could not create the lock file and check the running processes.
+ // It is possible that two installers with the same name get executed
+ // concurrently and thus try to access the same lock file. This causes
+ // a warning to be shown (when verbose output is enabled) but let's
+ // just silently ignore the fact that we could not create the lock file
+ // and check the running processes.
if (runCheck.isRunning(RunOnceChecker::ConditionFlag::ProcessList)) {
QInstaller::MessageBoxHandler::information(0, QLatin1String("AlreadyRunning"),
QString::fromLatin1("Waiting for %1").arg(qAppName()),