summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels Weber <niels.weber@digia.com>2014-03-26 10:22:41 +0100
committerNiels Weber <niels.weber@digia.com>2014-03-26 13:22:18 +0100
commitfe271082d87173762b50093e15f05360b25e23df (patch)
treeaffb39621f0e9bc361fe04444abe02c54b72cfa5
parent23d0dc225dbe3f89d0411c0195d8bcd066c3bdc7 (diff)
Warn earlier about trying to install to root or home path.
Change-Id: Ic5e6e207a140158edc15c09c6cf7af3b36ac1139 Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
-rw-r--r--src/sdk/installerbasecommons.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/sdk/installerbasecommons.cpp b/src/sdk/installerbasecommons.cpp
index f44cb409e..263eb5767 100644
--- a/src/sdk/installerbasecommons.cpp
+++ b/src/sdk/installerbasecommons.cpp
@@ -399,6 +399,19 @@ QString TargetDirectoryPageImpl::targetDirWarning() const
"absolute path.");
}
+ QDir target(targetDir());
+ target = target.canonicalPath();
+
+ if (target.isRoot()) {
+ return TargetDirectoryPageImpl::tr("As the install directory is completely deleted, installing "
+ "in %1 is forbidden.").arg(QDir::toNativeSeparators(QDir::rootPath()));
+ }
+
+ if (target == QDir::home()) {
+ return TargetDirectoryPageImpl::tr("As the install directory is completely deleted, installing "
+ "in %1 is forbidden.").arg(QDir::toNativeSeparators(QDir::homePath()));
+ }
+
QString dir = QDir::toNativeSeparators(targetDir());
#ifdef Q_OS_WIN
// folder length (set by user) + maintenance tool name length (no extension) + extra padding
@@ -479,11 +492,6 @@ bool TargetDirectoryPageImpl::validatePage()
const QFileInfo fi(targetDir);
if (fi.isDir()) {
- if (dir == QDir::root() || dir == QDir::home()) {
- return failWithError(QLatin1String("ForbiddenTargetDirectory"), tr("As the install directory "
- "is completely deleted installing in %1 is forbidden.").arg(QDir::rootPath()));
- }
-
QString fileName = packageManagerCore()->settings().uninstallerName();
#if defined(Q_OS_MAC)
if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle())