From b9a1fa36459c91d7aa4d6155f1ccced83214453f Mon Sep 17 00:00:00 2001 From: Soup <43444191+Soup-64@users.noreply.github.com> Date: Sat, 5 Apr 2025 22:26:58 -0400 Subject: [PATCH 1/4] Implement popup for metacache someone in the Discord ran into an issue somewhat related to the metacache button not working (folder in use err), so this warning makes it more obvious when this happens, though it would be better to find out why it ran into a process conflict Signed-off-by: Soup <43444191+Soup-64@users.noreply.github.com> --- launcher/FileSystem.cpp | 1 + launcher/net/HttpMetaCache.cpp | 6 ++++-- launcher/net/HttpMetaCache.h | 2 +- launcher/ui/MainWindow.cpp | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 954e7936e..14b50768a 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -55,6 +55,7 @@ #include "DesktopServices.h" #include "PSaveFile.h" #include "StringUtils.h" +#include "ui/dialogs/CustomMessageBox.h" #if defined Q_OS_WIN32 #define NOMINMAX diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp index 4985ad080..f57aad1ba 100644 --- a/launcher/net/HttpMetaCache.cpp +++ b/launcher/net/HttpMetaCache.cpp @@ -166,8 +166,9 @@ auto HttpMetaCache::evictEntry(MetaEntryPtr entry) -> bool return true; } -void HttpMetaCache::evictAll() +bool HttpMetaCache::evictAll() { + bool ret; for (QString& base : m_entries.keys()) { EntryMap& map = m_entries[base]; qCDebug(taskHttpMetaCacheLogC) << "Evicting base" << base; @@ -176,8 +177,9 @@ void HttpMetaCache::evictAll() qCWarning(taskHttpMetaCacheLogC) << "Unexpected missing cache entry" << entry->m_basePath; } map.entry_list.clear(); - FS::deletePath(map.base_path); + ret = FS::deletePath(map.base_path); } + return ret; } auto HttpMetaCache::staleEntry(QString base, QString resource_path) -> MetaEntryPtr diff --git a/launcher/net/HttpMetaCache.h b/launcher/net/HttpMetaCache.h index 036a8dd94..144012ae5 100644 --- a/launcher/net/HttpMetaCache.h +++ b/launcher/net/HttpMetaCache.h @@ -113,7 +113,7 @@ class HttpMetaCache : public QObject { // evict selected entry from cache auto evictEntry(MetaEntryPtr entry) -> bool; - void evictAll(); + bool evictAll(); void addBase(QString base, QString base_root); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index ddf726373..2b43af2b8 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1318,7 +1318,10 @@ void MainWindow::on_actionReportBug_triggered() void MainWindow::on_actionClearMetadata_triggered() { - APPLICATION->metacache()->evictAll(); + if(!APPLICATION->metacache()->evictAll()){ + CustomMessageBox::selectable(this, tr("Error"), tr("Metadata cache clear Failed!\n To clear the metadata cache manually, press Folders -> View Launcher Root Folder, and after closing the launcher delete the folder named \"meta\"\n"), QMessageBox::Warning)->show(); + } + APPLICATION->metacache()->SaveNow(); } From 0c90530f8859125ea762b6460e180c32096e8987 Mon Sep 17 00:00:00 2001 From: Soup <43444191+Soup-64@users.noreply.github.com> Date: Sun, 6 Apr 2025 15:27:49 -0400 Subject: [PATCH 2/4] cleanup Fix formatting and fix a typo in the return code check Signed-off-by: Soup <43444191+Soup-64@users.noreply.github.com> --- launcher/net/HttpMetaCache.cpp | 8 +++++--- launcher/net/HttpMetaCache.h | 2 +- launcher/ui/MainWindow.cpp | 9 +++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp index f57aad1ba..5a3a451b7 100644 --- a/launcher/net/HttpMetaCache.cpp +++ b/launcher/net/HttpMetaCache.cpp @@ -166,9 +166,10 @@ auto HttpMetaCache::evictEntry(MetaEntryPtr entry) -> bool return true; } -bool HttpMetaCache::evictAll() +//returns true on success, false otherwise +auto HttpMetaCache::evictAll() -> bool { - bool ret; + bool ret = true; for (QString& base : m_entries.keys()) { EntryMap& map = m_entries[base]; qCDebug(taskHttpMetaCacheLogC) << "Evicting base" << base; @@ -177,7 +178,8 @@ bool HttpMetaCache::evictAll() qCWarning(taskHttpMetaCacheLogC) << "Unexpected missing cache entry" << entry->m_basePath; } map.entry_list.clear(); - ret = FS::deletePath(map.base_path); + //AND all return codes together so the result is true iff all runs of deletePath() are true + ret &= FS::deletePath(map.base_path); } return ret; } diff --git a/launcher/net/HttpMetaCache.h b/launcher/net/HttpMetaCache.h index 144012ae5..5db41259f 100644 --- a/launcher/net/HttpMetaCache.h +++ b/launcher/net/HttpMetaCache.h @@ -113,7 +113,7 @@ class HttpMetaCache : public QObject { // evict selected entry from cache auto evictEntry(MetaEntryPtr entry) -> bool; - bool evictAll(); + auto evictAll() -> bool; void addBase(QString base, QString base_root); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 2b43af2b8..887d89006 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1318,8 +1318,13 @@ void MainWindow::on_actionReportBug_triggered() void MainWindow::on_actionClearMetadata_triggered() { - if(!APPLICATION->metacache()->evictAll()){ - CustomMessageBox::selectable(this, tr("Error"), tr("Metadata cache clear Failed!\n To clear the metadata cache manually, press Folders -> View Launcher Root Folder, and after closing the launcher delete the folder named \"meta\"\n"), QMessageBox::Warning)->show(); + //This if contains side effects! + if (!APPLICATION->metacache()->evictAll()) { + CustomMessageBox::selectable(this, tr("Error"), + tr("Metadata cache clear Failed!\nTo clear the metadata cache manually, press Folders -> View " + "Launcher Root Folder, and after closing the launcher delete the folder named \"meta\"\n"), + QMessageBox::Warning) + ->show(); } APPLICATION->metacache()->SaveNow(); From 25d7db207d3ddaca7d812754453c1e5385a3f80e Mon Sep 17 00:00:00 2001 From: Soup of the tomato kind <43444191+Soup-64@users.noreply.github.com> Date: Sun, 6 Apr 2025 16:15:02 -0400 Subject: [PATCH 3/4] Update FileSystem.cpp fix oopsie Signed-off-by: Soup of the tomato kind <43444191+Soup-64@users.noreply.github.com> --- launcher/FileSystem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 14b50768a..954e7936e 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -55,7 +55,6 @@ #include "DesktopServices.h" #include "PSaveFile.h" #include "StringUtils.h" -#include "ui/dialogs/CustomMessageBox.h" #if defined Q_OS_WIN32 #define NOMINMAX From 9b3fa591d3d6d0d09a5a164bfcc6356ae74932a7 Mon Sep 17 00:00:00 2001 From: Soup of the tomato kind <43444191+Soup-64@users.noreply.github.com> Date: Sun, 6 Apr 2025 16:24:09 -0400 Subject: [PATCH 4/4] Update launcher/net/HttpMetaCache.h Co-authored-by: Alexandru Ionut Tripon Signed-off-by: Soup of the tomato kind <43444191+Soup-64@users.noreply.github.com> --- launcher/net/HttpMetaCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/net/HttpMetaCache.h b/launcher/net/HttpMetaCache.h index 5db41259f..144012ae5 100644 --- a/launcher/net/HttpMetaCache.h +++ b/launcher/net/HttpMetaCache.h @@ -113,7 +113,7 @@ class HttpMetaCache : public QObject { // evict selected entry from cache auto evictEntry(MetaEntryPtr entry) -> bool; - auto evictAll() -> bool; + bool evictAll(); void addBase(QString base, QString base_root);