Very Temporary Fix for curseforge
This commit is contained in:
parent
1e6df7eec0
commit
6afe59e76b
@ -31,7 +31,21 @@ void Flame::FileResolvingTask::netJobFinished()
|
|||||||
for (auto& bytes : results) {
|
for (auto& bytes : results) {
|
||||||
auto& out = m_toProcess.files[index];
|
auto& out = m_toProcess.files[index];
|
||||||
try {
|
try {
|
||||||
failed &= (!out.parseFromBytes(bytes));
|
bool fail = (!out.parseFromBytes(bytes));
|
||||||
|
if(fail){
|
||||||
|
//failed :( probably disabled mod, try to add to the list
|
||||||
|
auto doc = Json::requireDocument(bytes);
|
||||||
|
if (!doc.isObject()) {
|
||||||
|
throw JSONValidationError(QString("data is not an object? that's not supposed to happen"));
|
||||||
|
}
|
||||||
|
auto obj = Json::ensureObject(doc.object(), "data");
|
||||||
|
//FIXME : HACK, MAY NOT WORK FOR LONG
|
||||||
|
out.url = QUrl(QString("https://media.forgecdn.net/files/%1/%2/%3")
|
||||||
|
.arg(QString::number(QString::number(out.fileId).leftRef(4).toInt())
|
||||||
|
,QString::number(QString::number(out.fileId).rightRef(3).toInt())
|
||||||
|
,QUrl::toPercentEncoding(out.fileName)), QUrl::TolerantMode);
|
||||||
|
}
|
||||||
|
failed &= fail;
|
||||||
} catch (const JSONValidationError& e) {
|
} catch (const JSONValidationError& e) {
|
||||||
qCritical() << "Resolving of" << out.projectId << out.fileId << "failed because of a parsing error:";
|
qCritical() << "Resolving of" << out.projectId << out.fileId << "failed because of a parsing error:";
|
||||||
qCritical() << e.cause();
|
qCritical() << e.cause();
|
||||||
|
@ -71,11 +71,6 @@ bool Flame::File::parseFromBytes(const QByteArray& bytes)
|
|||||||
|
|
||||||
fileName = Json::requireString(obj, "fileName");
|
fileName = Json::requireString(obj, "fileName");
|
||||||
|
|
||||||
QString rawUrl = Json::requireString(obj, "downloadUrl");
|
|
||||||
url = QUrl(rawUrl, QUrl::TolerantMode);
|
|
||||||
if (!url.isValid()) {
|
|
||||||
throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl));
|
|
||||||
}
|
|
||||||
// This is a piece of a Flame project JSON pulled out into the file metadata (here) for convenience
|
// This is a piece of a Flame project JSON pulled out into the file metadata (here) for convenience
|
||||||
// It is also optional
|
// It is also optional
|
||||||
type = File::Type::SingleFile;
|
type = File::Type::SingleFile;
|
||||||
@ -87,7 +82,16 @@ bool Flame::File::parseFromBytes(const QByteArray& bytes)
|
|||||||
// this is probably a mod, dunno what else could modpacks download
|
// this is probably a mod, dunno what else could modpacks download
|
||||||
targetFolder = "mods";
|
targetFolder = "mods";
|
||||||
}
|
}
|
||||||
|
if(!obj.contains("downloadUrl") || obj["downloadUrl"].isNull() || !obj["downloadUrl"].isString() || obj["downloadUrl"].toString().isEmpty()){
|
||||||
|
//either there somehow is an emtpy string as a link, or it's null either way it's invalid
|
||||||
|
//soft failing
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QString rawUrl = Json::requireString(obj, "downloadUrl");
|
||||||
|
url = QUrl(rawUrl, QUrl::TolerantMode);
|
||||||
|
if (!url.isValid()) {
|
||||||
|
throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl));
|
||||||
|
}
|
||||||
resolved = true;
|
resolved = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,90 +1,97 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>FlamePage</class>
|
<class>FlamePage</class>
|
||||||
<widget class="QWidget" name="FlamePage">
|
<widget class="QWidget" name="FlamePage">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>837</width>
|
<width>1989</width>
|
||||||
<height>685</height>
|
<height>685</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="0" column="1">
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<widget class="QPushButton" name="searchButton">
|
||||||
<item row="1" column="0">
|
<property name="text">
|
||||||
<widget class="QListView" name="packView">
|
<string>Search</string>
|
||||||
<property name="iconSize">
|
</property>
|
||||||
<size>
|
</widget>
|
||||||
<width>48</width>
|
</item>
|
||||||
<height>48</height>
|
<item row="0" column="0">
|
||||||
</size>
|
<widget class="QLineEdit" name="searchEdit">
|
||||||
</property>
|
<property name="placeholderText">
|
||||||
<property name="horizontalScrollBarPolicy">
|
<string>Search and filter...</string>
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="alternatingRowColors">
|
</item>
|
||||||
<bool>true</bool>
|
<item row="2" column="0" colspan="2">
|
||||||
</property>
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
</widget>
|
<item row="1" column="0">
|
||||||
</item>
|
<widget class="QListView" name="packView">
|
||||||
<item row="1" column="1">
|
<property name="horizontalScrollBarPolicy">
|
||||||
<widget class="QTextBrowser" name="packDescription">
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
<property name="openExternalLinks">
|
</property>
|
||||||
<bool>true</bool>
|
<property name="alternatingRowColors">
|
||||||
</property>
|
<bool>true</bool>
|
||||||
<property name="openLinks">
|
</property>
|
||||||
<bool>true</bool>
|
<property name="iconSize">
|
||||||
</property>
|
<size>
|
||||||
</widget>
|
<width>48</width>
|
||||||
</item>
|
<height>48</height>
|
||||||
</layout>
|
</size>
|
||||||
</item>
|
</property>
|
||||||
<item row="2" column="0" colspan="2">
|
</widget>
|
||||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0" columnminimumwidth="0,0,0">
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="versionSelectionBox"/>
|
<widget class="QTextBrowser" name="packDescription">
|
||||||
</item>
|
<property name="openExternalLinks">
|
||||||
<item row="0" column="1">
|
<bool>true</bool>
|
||||||
<widget class="QLabel" name="label">
|
</property>
|
||||||
<property name="text">
|
<property name="openLinks">
|
||||||
<string>Version selected:</string>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
</widget>
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
</item>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QComboBox" name="sortByBox"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QPushButton" name="searchButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Search</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLineEdit" name="searchEdit">
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Search and filter...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</item>
|
||||||
<tabstops>
|
<item row="3" column="0" colspan="2">
|
||||||
<tabstop>searchEdit</tabstop>
|
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0" columnminimumwidth="0,0,0">
|
||||||
<tabstop>searchButton</tabstop>
|
<item row="0" column="2">
|
||||||
<tabstop>packView</tabstop>
|
<widget class="QComboBox" name="versionSelectionBox"/>
|
||||||
<tabstop>packDescription</tabstop>
|
</item>
|
||||||
<tabstop>sortByBox</tabstop>
|
<item row="0" column="1">
|
||||||
<tabstop>versionSelectionBox</tabstop>
|
<widget class="QLabel" name="label">
|
||||||
</tabstops>
|
<property name="text">
|
||||||
<resources/>
|
<string>Version selected:</string>
|
||||||
<connections/>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QComboBox" name="sortByBox"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>WARNING !! Curseforge is very unreliable and low quality. Some mod authors have disabled the ability for third party apps (like polymc) to download the mods, you may need to manually download some mods</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>searchEdit</tabstop>
|
||||||
|
<tabstop>searchButton</tabstop>
|
||||||
|
<tabstop>packView</tabstop>
|
||||||
|
<tabstop>packDescription</tabstop>
|
||||||
|
<tabstop>sortByBox</tabstop>
|
||||||
|
<tabstop>versionSelectionBox</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user