From 48200db8b0e493602ce23f04255dde970cd7a7d5 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Tue, 7 Dec 2021 16:15:18 +0200 Subject: Fix selecting target directory when elevated server process is active There is a disparency in the return value of QFileInfo::isFile() on Windows whether QFileInfo uses QFileSystemEngine directly (for local files, returns false) or with another file engine (QFSFileEngine in this case, returns true), when the file does not exist on disk. Installer registers its own file engine handler that handles file engine creation. It creates custom RemoteFileEngine instances suitable for writing into more restrictive locations when the connection to the elevated installer server process is active. When calling RemoteFileEngine::fileFlags() with TypesMask parameter, the returned combination of enum values includes FileFlag::FileType when the given file does not exist, this can be reproduced with both the active remote server connection that forwards the file engine calls to the server process, and when the composed QFSFileEngine object is used directly without the remote connection. Fix by adding a check if the given target directory path exists, if it doesn't we can assume it is a directory to be created by the installer. Also rename function to better match what it does. Task-number: QTIFW-2383 Change-Id: I906b0676802d9d94e70abeb2dea1f71866cbbec8 Reviewed-by: Katja Marttila --- src/sdk/commandlineinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sdk') diff --git a/src/sdk/commandlineinterface.cpp b/src/sdk/commandlineinterface.cpp index 6b674364c..63deaf4d9 100644 --- a/src/sdk/commandlineinterface.cpp +++ b/src/sdk/commandlineinterface.cpp @@ -267,7 +267,7 @@ bool CommandLineInterface::setTargetDir() targetDir = m_core->value(QInstaller::scTargetDir); qCDebug(QInstaller::lcInstallerInstallLog) << "No target directory specified, using default value:" << targetDir; } - if (m_core->checkTargetDir(targetDir)) { + if (m_core->installationAllowedToDirectory(targetDir)) { QString targetDirWarning = m_core->targetDirWarning(targetDir); if (!targetDirWarning.isEmpty()) { qCWarning(QInstaller::lcInstallerInstallLog) << m_core->targetDirWarning(targetDir); -- cgit v1.2.3