From fe271082d87173762b50093e15f05360b25e23df Mon Sep 17 00:00:00 2001 From: Niels Weber Date: Wed, 26 Mar 2014 10:22:41 +0100 Subject: Warn earlier about trying to install to root or home path. Change-Id: Ic5e6e207a140158edc15c09c6cf7af3b36ac1139 Reviewed-by: Karsten Heimrich --- src/sdk/installerbasecommons.cpp | 18 +++++++++++++----- 1 file 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()) -- cgit v1.2.3