diff options
Diffstat (limited to 'launcher')
-rw-r--r-- | launcher/FileSystem.cpp | 2 | ||||
-rw-r--r-- | launcher/RuntimeContext.h | 32 | ||||
-rw-r--r-- | launcher/net/HttpMetaCache.cpp | 12 | ||||
-rw-r--r-- | launcher/net/HttpMetaCache.h | 1 | ||||
-rw-r--r-- | launcher/ui/MainWindow.cpp | 17 | ||||
-rw-r--r-- | launcher/ui/MainWindow.h | 2 |
6 files changed, 53 insertions, 13 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index c2db0dbc..39e68c20 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -187,7 +187,7 @@ bool copy::operator()(const QString& offset) // blacklisted paths, so we iterate over the source directory, and if there's no blacklist // match, we copy the file. QDir src_dir(src); - QDirIterator source_it(src, QDir::Filter::Files, QDirIterator::Subdirectories); + QDirIterator source_it(src, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::Subdirectories); while (source_it.hasNext()) { auto src_path = source_it.next(); diff --git a/launcher/RuntimeContext.h b/launcher/RuntimeContext.h index c1b71318..70e7d0d1 100644 --- a/launcher/RuntimeContext.h +++ b/launcher/RuntimeContext.h @@ -28,31 +28,38 @@ struct RuntimeContext { QString javaPath; QString system; - QString mappedJavaRealArchitecture() const { - if (javaRealArchitecture == "aarch64") { + QString mappedJavaRealArchitecture() const + { + if (javaRealArchitecture == "amd64") + return "x86_64"; + if (javaRealArchitecture == "i386" || javaRealArchitecture == "i686") + return "x86"; + if (javaRealArchitecture == "aarch64") return "arm64"; - } + if (javaRealArchitecture == "arm" || javaRealArchitecture == "armhf") + return "arm32"; return javaRealArchitecture; } - void updateFromInstanceSettings(SettingsObjectPtr instanceSettings) { + void updateFromInstanceSettings(SettingsObjectPtr instanceSettings) + { javaArchitecture = instanceSettings->get("JavaArchitecture").toString(); javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString(); javaPath = instanceSettings->get("JavaPath").toString(); system = currentSystem(); } - QString getClassifier() const { - return system + "-" + mappedJavaRealArchitecture(); - } + QString getClassifier() const { return system + "-" + mappedJavaRealArchitecture(); } // "Legacy" refers to the fact that Mojang assumed that these are the only two architectures - bool isLegacyArch() const { - QSet<QString> legacyArchitectures{"amd64", "x86_64", "i386", "i686", "x86"}; - return legacyArchitectures.contains(mappedJavaRealArchitecture()); + bool isLegacyArch() const + { + const QString mapped = mappedJavaRealArchitecture(); + return mapped == "x86_64" || mapped == "x86"; } - bool classifierMatches(QString target) const { + bool classifierMatches(QString target) const + { // try to match precise classifier "[os]-[arch]" bool x = target == getClassifier(); // try to match imprecise classifier on legacy architectures "[os]" @@ -62,7 +69,8 @@ struct RuntimeContext { return x; } - static QString currentSystem() { + static QString currentSystem() + { #if defined(Q_OS_LINUX) return "linux"; #elif defined(Q_OS_MACOS) diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp index 9606ddb6..42198b71 100644 --- a/launcher/net/HttpMetaCache.cpp +++ b/launcher/net/HttpMetaCache.cpp @@ -162,6 +162,18 @@ auto HttpMetaCache::evictEntry(MetaEntryPtr entry) -> bool return true; } +void HttpMetaCache::evictAll() +{ + for (QString& base : m_entries.keys()) { + EntryMap& map = m_entries[base]; + qDebug() << "Evicting base" << base; + for (MetaEntryPtr entry : map.entry_list) { + if (!evictEntry(entry)) + qWarning() << "Unexpected missing cache entry" << entry->basePath; + } + } +} + auto HttpMetaCache::staleEntry(QString base, QString resource_path) -> MetaEntryPtr { auto foo = new MetaEntry(); diff --git a/launcher/net/HttpMetaCache.h b/launcher/net/HttpMetaCache.h index c0b12318..2a07d65a 100644 --- a/launcher/net/HttpMetaCache.h +++ b/launcher/net/HttpMetaCache.h @@ -113,6 +113,7 @@ class HttpMetaCache : public QObject { // evict selected entry from cache auto evictEntry(MetaEntryPtr entry) -> bool; + void evictAll(); void addBase(QString base, QString base_root); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 55f7a28c..603eaa97 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -252,6 +252,7 @@ public: QMenu * helpMenu = nullptr; TranslatedToolButton helpMenuButton; + TranslatedAction actionClearMetadata; TranslatedAction actionReportBug; TranslatedAction actionDISCORD; TranslatedAction actionMATRIX; @@ -341,6 +342,13 @@ public: actionUndoTrashInstance->setShortcut(QKeySequence("Ctrl+Z")); all_actions.append(&actionUndoTrashInstance); + actionClearMetadata = TranslatedAction(MainWindow); + actionClearMetadata->setObjectName(QStringLiteral("actionClearMetadata")); + actionClearMetadata->setIcon(APPLICATION->getThemedIcon("refresh")); + actionClearMetadata.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Clear Metadata Cache")); + actionClearMetadata.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Clear cached metadata")); + all_actions.append(&actionClearMetadata); + if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) { actionReportBug = TranslatedAction(MainWindow); actionReportBug->setObjectName(QStringLiteral("actionReportBug")); @@ -439,6 +447,8 @@ public: helpMenu = new QMenu(MainWindow); helpMenu->setToolTipsVisible(true); + helpMenu->addAction(actionClearMetadata); + if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) { helpMenu->addAction(actionReportBug); } @@ -523,6 +533,8 @@ public: helpMenu = menuBar->addMenu(tr("&Help")); helpMenu->setSeparatorsCollapsible(false); + helpMenu->addAction(actionClearMetadata); + helpMenu->addSeparator(); helpMenu->addAction(actionAbout); helpMenu->addAction(actionOpenWiki); helpMenu->addAction(actionNewsMenuBar); @@ -1868,6 +1880,11 @@ void MainWindow::on_actionReportBug_triggered() DesktopServices::openUrl(QUrl(BuildConfig.BUG_TRACKER_URL)); } +void MainWindow::on_actionClearMetadata_triggered() +{ + APPLICATION->metacache()->evictAll(); +} + void MainWindow::on_actionOpenWiki_triggered() { DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg(""))); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index fc3f0816..cb8cb4aa 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -126,6 +126,8 @@ private slots: void on_actionReportBug_triggered(); + void on_actionClearMetadata_triggered(); + void on_actionOpenWiki_triggered(); void on_actionMoreNews_triggered(); |