summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-10-20 14:08:14 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-10-21 12:46:37 +0000
commit422202d41537729d6fcdb853f686a51f20239f18 (patch)
treeb2e570b13d44801bdb9e3db9a008844806edf08d
parent2dbb8c19ea19b9cef28e29899e50b788eded6f4d (diff)
CLI: Add new 'clear-cache' command
The command can be used to clear the contents of local metadata cache without opening the installer GUI. Task-number: QTIFW-2810 Change-Id: I18cec027b9945f83d25fa1716858756ececae6d4 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
-rw-r--r--doc/installerfw-using.qdoc13
-rw-r--r--doc/installerfw.qdoc3
-rw-r--r--src/libs/installer/commandlineparser.cpp2
-rw-r--r--src/libs/installer/constants.h6
-rw-r--r--src/sdk/commandlineinterface.cpp12
-rw-r--r--src/sdk/commandlineinterface.h1
-rw-r--r--src/sdk/main.cpp3
7 files changed, 39 insertions, 1 deletions
diff --git a/doc/installerfw-using.qdoc b/doc/installerfw-using.qdoc
index a2aac9046..1252bf548 100644
--- a/doc/installerfw-using.qdoc
+++ b/doc/installerfw-using.qdoc
@@ -479,6 +479,19 @@
installer.exe --root "C:\TargetFolder" --offline-installer-name "MyInstaller" create-offline componentA componentB
\endcode
+ \section1 Clearing the Local Cache
+
+ Online installers and maintenance tools created with the Qt Installer Framework cache the
+ meta information downloaded from remote repositories to local disk. This improves loading
+ times for subsequent metadata downloads.
+
+ The cache may grow in size over time. To clear the contents of the entire cache,
+ use the \c clear-cache command:
+
+ \code
+ maintenancetool.exe clear-cache
+ \endcode
+
\section1 Unattended Usage
By default, the generated installers may ask for additional information during installation,
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc
index e69a545b2..e1ade5a13 100644
--- a/doc/installerfw.qdoc
+++ b/doc/installerfw.qdoc
@@ -334,6 +334,9 @@
\li co, create-offline <pkg ...>
\li Create offline installer from selected packages.
\row
+ \li cc, clear-cache
+ \li Clear contents of the local metadata cache.
+ \row
\li pr, purge
\li Uninstall all packages and remove the program directory.
\endtable
diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp
index 2c09d14b4..fd870da2d 100644
--- a/src/libs/installer/commandlineparser.cpp
+++ b/src/libs/installer/commandlineparser.cpp
@@ -65,6 +65,8 @@ CommandLineParser::CommandLineParser()
+ indent + indent + QLatin1String("additional filters for the search operation\n")
+ indent + QString::fromLatin1("%1, %2 - create offline installer from selected packages - <pkg ...>\n")
.arg(CommandLineOptions::scCreateOfflineShort, CommandLineOptions::scCreateOfflineLong)
+ + indent + QString::fromLatin1("%1, %2 - clear contents of the local metadata cache\n")
+ .arg(CommandLineOptions::scClearCacheShort, CommandLineOptions::scClearCacheLong)
+ indent + QString::fromLatin1("%1, %2 - uninstall all packages and remove entire program directory")
.arg(CommandLineOptions::scPurgeShort, CommandLineOptions::scPurgeLong);
diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h
index 38223eaf3..77fc0237f 100644
--- a/src/libs/installer/constants.h
+++ b/src/libs/installer/constants.h
@@ -150,6 +150,8 @@ static const QLatin1String scSearchShort("se");
static const QLatin1String scSearchLong("search");
static const QLatin1String scCreateOfflineShort("co");
static const QLatin1String scCreateOfflineLong("create-offline");
+static const QLatin1String scClearCacheShort("cc");
+static const QLatin1String scClearCacheLong("clear-cache");
static const QLatin1String scPurgeShort("pr");
static const QLatin1String scPurgeLong("purge");
@@ -247,7 +249,9 @@ static const QStringList scCommandLineInterfaceOptions = {
scCreateOfflineShort,
scCreateOfflineLong,
scPurgeShort,
- scPurgeLong
+ scPurgeLong,
+ scClearCacheShort,
+ scClearCacheLong
};
} // namespace CommandLineOptions
diff --git a/src/sdk/commandlineinterface.cpp b/src/sdk/commandlineinterface.cpp
index 63deaf4d9..a1eea1f8d 100644
--- a/src/sdk/commandlineinterface.cpp
+++ b/src/sdk/commandlineinterface.cpp
@@ -248,6 +248,18 @@ int CommandLineInterface::createOfflineInstaller()
}
}
+int CommandLineInterface::clearLocalCache()
+{
+ if (!initialize())
+ return EXIT_FAILURE;
+
+ if (!m_core->clearLocalCache())
+ return EXIT_FAILURE;
+
+ qCDebug(QInstaller::lcInstallerInstallLog) << "Cache cleared successfully!";
+ return EXIT_SUCCESS;
+}
+
bool CommandLineInterface::checkLicense()
{
const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance();
diff --git a/src/sdk/commandlineinterface.h b/src/sdk/commandlineinterface.h
index 29bae74a4..aeaca780f 100644
--- a/src/sdk/commandlineinterface.h
+++ b/src/sdk/commandlineinterface.h
@@ -49,6 +49,7 @@ public:
int uninstallPackages();
int removeInstallation();
int createOfflineInstaller();
+ int clearLocalCache();
private:
bool initialize();
diff --git a/src/sdk/main.cpp b/src/sdk/main.cpp
index 4ab9348c8..f7368883b 100644
--- a/src/sdk/main.cpp
+++ b/src/sdk/main.cpp
@@ -331,6 +331,9 @@ int main(int argc, char *argv[])
} else if (parser.positionalArguments().contains(CommandLineOptions::scCreateOfflineShort)
|| parser.positionalArguments().contains(CommandLineOptions::scCreateOfflineLong)) {
return CommandLineInterface(argc, argv).createOfflineInstaller();
+ } else if (parser.positionalArguments().contains(CommandLineOptions::scClearCacheShort)
+ || parser.positionalArguments().contains(CommandLineOptions::scClearCacheLong)) {
+ return CommandLineInterface(argc, argv).clearLocalCache();
}
if (QInstaller::LoggingHandler::instance().isVerbose()) {
std::cout << VERSION << std::endl << BUILDDATE << std::endl << SHA << std::endl;