From b1b50fcb281efc7681c4520ddf1f19bae11b624c Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Tue, 20 Dec 2022 09:23:45 +0200 Subject: Optimize metadata validation QFile::open is time consuming operation in Windws. Metadata validation does not need to open the file, it is enough to check that the file exists in the expected location, thus using QFileInfo::exists() instead of QFile::open for metadata validation. Change-Id: Ic1cee9915db2f3359569ad772a4ac619c03f2446 Reviewed-by: Arttu Tarkiainen --- src/libs/installer/metadata.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/libs') diff --git a/src/libs/installer/metadata.cpp b/src/libs/installer/metadata.cpp index c90937bb8..9ae817127 100644 --- a/src/libs/installer/metadata.cpp +++ b/src/libs/installer/metadata.cpp @@ -123,15 +123,14 @@ QDomDocument Metadata::updatesDocument() const /*! Returns \c true if the \c Updates.xml document of this metadata - exists and can be opened for reading, \c false otherwise. + exists, \c false otherwise. */ bool Metadata::isValid() const { - QFile updateFile(path() + QLatin1String("/Updates.xml")); - if (!updateFile.open(QIODevice::ReadOnly)) { + const QString updateFile(path() + QLatin1String("/Updates.xml")); + if (!QFileInfo::exists(updateFile)) { qCWarning(QInstaller::lcInstallerInstallLog) - << "Cannot open" << updateFile.fileName() - << "for reading:" << updateFile.errorString(); + << "File" << updateFile << "does not exist."; return false; } return true; -- cgit v1.2.3