diff options
author | Frerich Raabe <raabe@froglogic.com> | 2016-06-02 11:40:47 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2016-06-15 08:54:46 +0000 |
commit | b4a1a89e306367feaec56ce9902d15234ece5f84 (patch) | |
tree | 5807e51d2b77c4df676136444726f2a003bd3c6a /src/sdk | |
parent | f11fce311bb954457da1641ccbc6684e7cdd3418 (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')
-rw-r--r-- | src/sdk/installerbase.cpp | 12 | ||||
-rw-r--r-- | src/sdk/updatechecker.cpp | 3 |
2 files changed, 9 insertions, 6 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()), diff --git a/src/sdk/updatechecker.cpp b/src/sdk/updatechecker.cpp index 1276ea436..823c94c27 100644 --- a/src/sdk/updatechecker.cpp +++ b/src/sdk/updatechecker.cpp @@ -41,6 +41,7 @@ #include <packagemanagercore.h> #include <productkeycheck.h> +#include <QDir> #include <QDomDocument> #include <iostream> @@ -53,7 +54,7 @@ UpdateChecker::UpdateChecker(int &argc, char *argv[]) int UpdateChecker::check() { - RunOnceChecker runCheck(qApp->applicationDirPath() + RunOnceChecker runCheck(QDir::tempPath() + QLatin1Char('/') + qApp->applicationName() + QLatin1String("15021976.lock")); |