Skip to content

Commit ca9cb40

Browse files
authored
feat(metadata): download EPL metadata from our own server (#101)
2 parents 1ea95c7 + 43a59e9 commit ca9cb40

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ set(Launcher_BUILD_ARTIFACT "" CACHE STRING "Artifact name to help the updater i
217217
# The metadata server
218218
set(Launcher_META_URL "https://meta.prismlauncher.org/v1/" CACHE STRING "URL to fetch Launcher's meta files from.")
219219

220+
# Ely.by metadata URL
221+
set(Launcher_EPL_META_URL "https://freesmlauncher.org/metadata/epl_metadata.json" CACHE STRING "URL to fetch Ely authlibs metadata")
222+
223+
# Ely.by metadata fallback URL
224+
set(Launcher_EPL_META_FALLBACK_URL "https://raw.githubusercontent.com/FreesmTeam/FreesmLauncher/refs/heads/develop/epl_metadata.json" CACHE STRING "Fallback URL to fetch Ely authlibs metadata")
225+
220226
# Imgur API Client ID
221227
set(Launcher_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can get from Imgur when you register an application")
222228

buildconfig/BuildConfig.cpp.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ Config::Config()
125125
ELYBY_CLIENT_ID = "@Launcher_ELYBY_CLIENT_ID@";
126126
FLAME_API_KEY = "@Launcher_CURSEFORGE_API_KEY@";
127127
META_URL = "@Launcher_META_URL@";
128+
EPL_META_URL = "@Launcher_EPL_META_URL@";
129+
EPL_META_FALLBACK_URL = "@Launcher_EPL_META_FALLBACK_URL@";
128130
FMLLIBS_BASE_URL = "@Launcher_FMLLIBS_BASE_URL@";
129131

130132
GLFW_LIBRARY_NAME = "@Launcher_GLFW_LIBRARY_NAME@";

buildconfig/BuildConfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class Config {
172172
*/
173173
QString META_URL;
174174

175+
QString EPL_META_URL;
176+
QString EPL_META_FALLBACK_URL;
177+
175178
QString GLFW_LIBRARY_NAME;
176179
QString OPENAL_LIBRARY_NAME;
177180

launcher/minecraft/launch/ApplyLibraryOverrides.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include "ApplyLibraryOverrides.h"
2-
#include <launch/LaunchTask.h>
2+
#include "Application.h"
3+
#include "BuildConfig.h"
4+
#include "launch/LaunchTask.h"
35
#include "minecraft/PackProfile.h"
46
#include "net/Download.h"
57
#include "net/NetJob.h"
68

7-
#include "Application.h"
8-
99
ApplyLibraryOverrides::ApplyLibraryOverrides(LaunchTask* parent, AuthSessionPtr session)
1010
: LaunchStep(parent), m_session(session), m_instance(m_parent->instance())
1111
{}
@@ -17,13 +17,13 @@ void ApplyLibraryOverrides::executeTask()
1717

1818
void ApplyLibraryOverrides::downloadLibraryOverrideList()
1919
{
20-
const auto libraryOverrideListUrl =
21-
QUrl("https://raw.githubusercontent.com/FreesmTeam/FreesmLauncher/refs/heads/develop/epl_metadata.json");
20+
const auto libraryOverrideListUrl = QUrl(m_isFirstDownloadTry ? BuildConfig.EPL_META_URL : BuildConfig.EPL_META_FALLBACK_URL);
2221
m_response = std::make_shared<QByteArray>();
2322
m_request = Net::Download::makeByteArray(libraryOverrideListUrl, m_response);
2423

2524
m_task.reset(new NetJob("Fetch EPL metadata", APPLICATION->network()));
2625
m_task->addNetAction(m_request);
26+
m_task->setAskRetry(false);
2727

2828
connect(m_task.get(), &NetJob::finished, this, &ApplyLibraryOverrides::onLibraryOverrideDownloadFinished);
2929
connect(m_task.get(), &NetJob::aborted, this, [this] { emitFailed(tr("Aborted")); });
@@ -34,6 +34,10 @@ void ApplyLibraryOverrides::downloadLibraryOverrideList()
3434
void ApplyLibraryOverrides::onLibraryOverrideDownloadFinished()
3535
{
3636
if (m_request->error() != QNetworkReply::NoError) {
37+
if (m_isFirstDownloadTry) {
38+
m_isFirstDownloadTry = false;
39+
return downloadLibraryOverrideList();
40+
}
3741
emitFailed("Failed to download EPL metadata.");
3842
return;
3943
}

launcher/minecraft/launch/ApplyLibraryOverrides.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ class ApplyLibraryOverrides : public LaunchStep {
3838
std::shared_ptr<QByteArray> m_response = std::make_shared<QByteArray>();
3939
Net::Download::Ptr m_request;
4040
NetJob::Ptr m_task;
41+
bool m_isFirstDownloadTry = true;
4142
};

0 commit comments

Comments
 (0)