mirror of
https://github.com/QuasarApp/installer-framework.git
synced 2025-04-30 23:44:33 +00:00
Fix broken target directory handling.
Files and syminks are not allowed as target dir either. Fixes a broken check if the selected target contains an installation already. Do not complain on empty targets.
This commit is contained in:
parent
1f2883f47a
commit
c31eddb8fa
@ -32,6 +32,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
#include "installerbasecommons.h"
|
#include "installerbasecommons.h"
|
||||||
|
|
||||||
|
#include <common/installersettings.h>
|
||||||
#include <messageboxhandler.h>
|
#include <messageboxhandler.h>
|
||||||
#include <qinstaller.h>
|
#include <qinstaller.h>
|
||||||
#include <qinstallercomponent.h>
|
#include <qinstallercomponent.h>
|
||||||
@ -236,9 +237,13 @@ bool TargetDirectoryPageImpl::validatePage()
|
|||||||
if (!QVariant(remove).toBool())
|
if (!QVariant(remove).toBool())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (QFileInfo(targetDir()).isDir()) {
|
const QDir dir(targetDir());
|
||||||
QFileInfo fi2(targetDir() + QDir::separator() + installer()->uninstallerName());
|
if (dir.exists() && dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty())
|
||||||
if (QDir(targetDir()) == QDir::root()) {
|
return true;
|
||||||
|
|
||||||
|
QFileInfo fi(targetDir());
|
||||||
|
if (fi.isDir()) {
|
||||||
|
if (dir == QDir::root()) {
|
||||||
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
|
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
|
||||||
QLatin1String("forbiddenTargetDirectory"), tr("Error"),
|
QLatin1String("forbiddenTargetDirectory"), tr("Error"),
|
||||||
tr("As the install directory is completely deleted installing in %1 is forbidden")
|
tr("As the install directory is completely deleted installing in %1 is forbidden")
|
||||||
@ -246,6 +251,15 @@ bool TargetDirectoryPageImpl::validatePage()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString fileName = installer()->settings().uninstallerName();
|
||||||
|
#if defined(Q_WS_MAC)
|
||||||
|
if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle())
|
||||||
|
fileName += QLatin1String(".app/Contents/MacOS/") + fileName;
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
fileName += QLatin1String(".exe");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QFileInfo fi2(targetDir() + QDir::separator() + fileName);
|
||||||
if (fi2.exists()) {
|
if (fi2.exists()) {
|
||||||
return askQuestion(QLatin1String("overwriteTargetDirectory"),
|
return askQuestion(QLatin1String("overwriteTargetDirectory"),
|
||||||
TargetDirectoryPageImpl::tr("The folder you selected exists already and "
|
TargetDirectoryPageImpl::tr("The folder you selected exists already and "
|
||||||
@ -257,6 +271,12 @@ bool TargetDirectoryPageImpl::validatePage()
|
|||||||
"Note that it will be completely wiped on uninstallation of this application.\n"
|
"Note that it will be completely wiped on uninstallation of this application.\n"
|
||||||
"It is not advisable to install into this folder as installation might fail.\n"
|
"It is not advisable to install into this folder as installation might fail.\n"
|
||||||
"Do you want to continue?"));
|
"Do you want to continue?"));
|
||||||
|
} else if (fi.isFile() || fi.isSymLink()) {
|
||||||
|
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
|
||||||
|
QLatin1String("WrongTargetDirectory"), tr("Error"),
|
||||||
|
tr("You have selected an existing file or symlink, please choose a different target for "
|
||||||
|
"installation."), QMessageBox::Ok);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1143,11 +1143,11 @@ bool TargetDirectoryPage::validatePage()
|
|||||||
{
|
{
|
||||||
if (targetDir().isEmpty()) {
|
if (targetDir().isEmpty()) {
|
||||||
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
|
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
|
||||||
QLatin1String("forbiddenTargetDirectory"), tr("Error"),
|
QLatin1String("forbiddenTargetDirectory"), tr("Error"),
|
||||||
tr( "The install directory cannot be empty, please specify a valid folder"),
|
tr( "The install directory cannot be empty, please specify a valid folder"), QMessageBox::Ok);
|
||||||
QMessageBox::Ok);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDir dir(targetDir());
|
const QDir dir(targetDir());
|
||||||
// it exists, but is empty (might be created by the Browse button (getExistingDirectory)
|
// it exists, but is empty (might be created by the Browse button (getExistingDirectory)
|
||||||
if (dir.exists() && dir.entryList(QDir::NoDotAndDotDot).isEmpty()) {
|
if (dir.exists() && dir.entryList(QDir::NoDotAndDotDot).isEmpty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user