Skip to content

Commit 3e41120

Browse files
committed
fix: only evict actual meta during automatic server switching
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
1 parent dea44b7 commit 3e41120

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

launcher/PineconeNetworkCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void PineconeNetworkCheck::finished()
9494
{ Result::UseOldFallback, "https://elyprismlauncher.github.io/meta/v1/" },
9595
};
9696
if (handleUrlOverride("MetaURLOverride", metaUrls)) {
97-
if (!APPLICATION->metacache()->evictAll()) {
97+
if (!APPLICATION->metacache()->softEvict()) {
9898
qWarning() << "Could not evict metacache during automatic meta switch";
9999
}
100100
APPLICATION->metacache()->SaveNow();

launcher/net/HttpMetaCache.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,17 @@ auto HttpMetaCache::evictAll() -> bool
187187
return ret;
188188
}
189189

190+
bool HttpMetaCache::softEvict()
191+
{
192+
auto& [base_path, entry_list] = m_entries["meta"];
193+
for (const MetaEntryPtr& entry : entry_list) {
194+
if (!evictEntry(entry))
195+
qCWarning(taskHttpMetaCacheLogC) << "Unexpected missing cache entry" << entry->m_basePath;
196+
}
197+
entry_list.clear();
198+
return FS::deletePath(base_path);
199+
}
200+
190201
auto HttpMetaCache::staleEntry(QString base, QString resource_path) -> MetaEntryPtr
191202
{
192203
auto foo = new MetaEntry();

launcher/net/HttpMetaCache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class HttpMetaCache : public QObject {
115115
auto evictEntry(MetaEntryPtr entry) -> bool;
116116
bool evictAll();
117117

118+
// evict meta only
119+
bool softEvict();
120+
118121
void addBase(QString base, QString base_root);
119122

120123
// (re)start a timer that calls SaveNow later.

0 commit comments

Comments
 (0)