mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-09-23 06:05:25 -04:00
rename: rsp to res
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
35 files changed
+177
-181
No files matched your search
+19
-19
@@ -268,11 +268,11 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext& context, const QSt
|
||||
|
||||
std::tuple<QDateTime, QString, QString, QString, QString> readLockFile(const QString& path)
|
||||
{
|
||||
auto rsp = FS::read(path);
|
||||
if (!rsp) {
|
||||
unrecoverable("Failed to read lock file: " + rsp.error());
|
||||
auto res = FS::read(path);
|
||||
if (!res) {
|
||||
unrecoverable("Failed to read lock file: " + res.error());
|
||||
}
|
||||
auto contents = QString(rsp.value());
|
||||
auto contents = QString(res.value());
|
||||
auto lines = contents.split('\n');
|
||||
|
||||
QDateTime timestamp;
|
||||
@@ -1114,11 +1114,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
auto msgBox = QMessageBox(QMessageBox::Warning, tr("Update In Progress"), infoMsg, QMessageBox::Ignore | QMessageBox::Abort);
|
||||
msgBox.setDefaultButton(QMessageBox::Abort);
|
||||
msgBox.setModal(true);
|
||||
auto rsp = FS::read(updateLogPath);
|
||||
if (!rsp) {
|
||||
unrecoverable("Failed to read update log: " + rsp.error());
|
||||
auto maybeRes = FS::read(updateLogPath);
|
||||
if (!maybeRes) {
|
||||
unrecoverable("Failed to read update log: " + maybeRes.error());
|
||||
}
|
||||
msgBox.setDetailedText(rsp.value());
|
||||
msgBox.setDetailedText(maybeRes.value());
|
||||
msgBox.setMinimumWidth(460);
|
||||
msgBox.adjustSize();
|
||||
auto res = msgBox.exec();
|
||||
@@ -1150,11 +1150,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
auto msgBox = QMessageBox(QMessageBox::Warning, tr("Update Failed"), infoMsg, QMessageBox::Ignore | QMessageBox::Abort);
|
||||
msgBox.setDefaultButton(QMessageBox::Abort);
|
||||
msgBox.setModal(true);
|
||||
auto rsp = FS::read(updateLogPath);
|
||||
if (!rsp) {
|
||||
unrecoverable("Failed to read update log: " + rsp.error());
|
||||
auto maybeRes = FS::read(updateLogPath);
|
||||
if (!maybeRes) {
|
||||
unrecoverable("Failed to read update log: " + maybeRes.error());
|
||||
}
|
||||
msgBox.setDetailedText(rsp.value());
|
||||
msgBox.setDetailedText(maybeRes.value());
|
||||
msgBox.setMinimumWidth(460);
|
||||
msgBox.adjustSize();
|
||||
auto res = msgBox.exec();
|
||||
@@ -1185,11 +1185,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
.arg(updateLogPath);
|
||||
auto* msgBox = new QMessageBox(QMessageBox::Information, tr("Update Succeeded"), infoMsg, QMessageBox::Ok);
|
||||
msgBox->setDefaultButton(QMessageBox::Ok);
|
||||
auto rsp = FS::read(updateLogPath);
|
||||
if (!rsp) {
|
||||
unrecoverable("Failed to read update log: " + rsp.error());
|
||||
auto res = FS::read(updateLogPath);
|
||||
if (!res) {
|
||||
unrecoverable("Failed to read update log: " + res.error());
|
||||
}
|
||||
msgBox->setDetailedText(rsp.value());
|
||||
msgBox->setDetailedText(res.value());
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->setMinimumWidth(460);
|
||||
msgBox->adjustSize();
|
||||
@@ -1461,9 +1461,9 @@ Application::~Application()
|
||||
void Application::messageReceived(const QByteArray& message)
|
||||
{
|
||||
ApplicationMessage received;
|
||||
auto rsp = received.parse(message);
|
||||
if (!rsp) {
|
||||
qWarning() << "Received invalid message:" << rsp.error();
|
||||
auto res = received.parse(message);
|
||||
if (!res) {
|
||||
qWarning() << "Received invalid message:" << res.error();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -295,8 +295,8 @@ void FileIgnoreProxy::loadBlockedPathsFromFile(const QString& fileName)
|
||||
void FileIgnoreProxy::saveBlockedPathsToFile(const QString& fileName)
|
||||
{
|
||||
auto ignoreData = blockedPaths().toStringList().join('\n').toUtf8();
|
||||
auto rsp = FS::write(fileName, ignoreData);
|
||||
if (!rsp) {
|
||||
qWarning() << rsp.error();
|
||||
auto res = FS::write(fileName, ignoreData);
|
||||
if (!res) {
|
||||
qWarning() << res.error();
|
||||
}
|
||||
}
|
||||
@@ -189,9 +189,9 @@ namespace FS {
|
||||
|
||||
Result<> write(const QString& filename, const QByteArray& data)
|
||||
{
|
||||
auto rsp = ensureExists(QFileInfo(filename).dir());
|
||||
if (!rsp) {
|
||||
return rsp;
|
||||
auto res = ensureExists(QFileInfo(filename).dir());
|
||||
if (!res) {
|
||||
return res;
|
||||
}
|
||||
PSaveFile file(filename);
|
||||
if (!file.open(PSaveFile::WriteOnly)) {
|
||||
@@ -208,9 +208,9 @@ Result<> write(const QString& filename, const QByteArray& data)
|
||||
|
||||
Result<> appendSafe(const QString& filename, const QByteArray& data)
|
||||
{
|
||||
auto rsp = ensureExists(QFileInfo(filename).dir());
|
||||
if (!rsp) {
|
||||
return rsp;
|
||||
auto res = ensureExists(QFileInfo(filename).dir());
|
||||
if (!res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
QByteArray buffer;
|
||||
@@ -234,9 +234,9 @@ Result<> appendSafe(const QString& filename, const QByteArray& data)
|
||||
|
||||
Result<> append(const QString& filename, const QByteArray& data)
|
||||
{
|
||||
auto rsp = ensureExists(QFileInfo(filename).dir());
|
||||
if (!rsp) {
|
||||
return rsp;
|
||||
auto res = ensureExists(QFileInfo(filename).dir());
|
||||
if (!res) {
|
||||
return res;
|
||||
}
|
||||
QFile file(filename);
|
||||
if (!file.open(QFile::Append)) {
|
||||
|
||||
@@ -162,11 +162,11 @@ void InstanceCopyTask::copyFinished()
|
||||
|
||||
QByteArray allowedSymlinks;
|
||||
if (allowedSymlinksFile.exists()) {
|
||||
auto rsp = FS::read(allowedSymlinksFile.filePath());
|
||||
if (!rsp) {
|
||||
qCritical() << "Failed to read symlink" << rsp.error();
|
||||
auto res = FS::read(allowedSymlinksFile.filePath());
|
||||
if (!res) {
|
||||
qCritical() << "Failed to read symlink" << res.error();
|
||||
} else {
|
||||
allowedSymlinks.append(rsp.value());
|
||||
allowedSymlinks.append(res.value());
|
||||
if (allowedSymlinks.right(1) != "\n") {
|
||||
allowedSymlinks.append("\n"); // we want to be on a new line
|
||||
}
|
||||
@@ -180,9 +180,9 @@ void InstanceCopyTask::copyFinished()
|
||||
.filePath()); // we dont want to modify the original. also make sure the resulting file is not itself a link.
|
||||
}
|
||||
|
||||
auto rsp = FS::write(allowedSymlinksFile.filePath(), allowedSymlinks);
|
||||
if (!rsp) {
|
||||
qCritical() << "Failed to write symlink :" << rsp.error();
|
||||
auto res = FS::write(allowedSymlinksFile.filePath(), allowedSymlinks);
|
||||
if (!res) {
|
||||
qCritical() << "Failed to write symlink :" << res.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -791,9 +791,9 @@ void InstanceList::saveGroupList()
|
||||
toplevel.insert("ungrouped", ungrouped);
|
||||
}
|
||||
QJsonDocument doc(toplevel);
|
||||
auto rsp = FS::write(groupFileName, doc.toJson());
|
||||
if (!rsp) {
|
||||
qCritical() << "Failed to write instance group file :" << rsp.error();
|
||||
auto res = FS::write(groupFileName, doc.toJson());
|
||||
if (!res) {
|
||||
qCritical() << "Failed to write instance group file :" << res.error();
|
||||
} else {
|
||||
qDebug() << "Group list saved.";
|
||||
}
|
||||
@@ -822,12 +822,12 @@ void InstanceList::loadGroupList()
|
||||
migratingLegacyGroups = true;
|
||||
}
|
||||
|
||||
auto rsp = FS::read(groupFileName);
|
||||
if (!rsp) {
|
||||
qCritical() << "Failed to read instance group file :" << rsp.error();
|
||||
auto res = FS::read(groupFileName);
|
||||
if (!res) {
|
||||
qCritical() << "Failed to read instance group file :" << res.error();
|
||||
return;
|
||||
}
|
||||
const auto& jsonData = rsp.value();
|
||||
const auto& jsonData = res.value();
|
||||
|
||||
auto jsonDoc = Json::requireObject(jsonData);
|
||||
|
||||
|
||||
@@ -107,10 +107,10 @@ void BaseEntityLoadTask::executeTask()
|
||||
if (m_entity->m_load_status == BaseEntity::LoadStatus::NotLoaded || m_entity->m_file_sha256.isEmpty()) {
|
||||
setStatus(tr("Loading local file"));
|
||||
|
||||
auto rsp = FS::read(fname);
|
||||
TRY(rsp)
|
||||
auto res = FS::read(fname);
|
||||
TRY(res)
|
||||
|
||||
fileData = rsp.value();
|
||||
fileData = res.value();
|
||||
m_entity->m_file_sha256 = Hashing::hash(fileData, Hashing::Algorithm::Sha256);
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ void BaseEntityLoadTask::executeTask()
|
||||
}
|
||||
return {};
|
||||
};
|
||||
auto rsp = parse();
|
||||
if (!rsp) {
|
||||
qCritical() << QString("Unable to parse file %1: %2").arg(fname, rsp.error());
|
||||
auto res = parse();
|
||||
if (!res) {
|
||||
qCritical() << QString("Unable to parse file %1: %2").arg(fname, res.error());
|
||||
// just make sure it's gone and we never consider it again.
|
||||
FS::deletePath(fname);
|
||||
m_entity->m_load_status = BaseEntity::LoadStatus::NotLoaded;
|
||||
|
||||
@@ -1090,8 +1090,8 @@ QString MinecraftInstance::getStatusbarDescription()
|
||||
QString mcVersion = m_components->getComponentVersion("net.minecraft");
|
||||
if (mcVersion.isEmpty()) {
|
||||
// Load component info if needed
|
||||
if (auto rsp = m_components->reload(Net::Mode::Offline); !rsp) {
|
||||
qWarning() << "Failed to reload components:" << rsp.error();
|
||||
if (auto res = m_components->reload(Net::Mode::Offline); !res) {
|
||||
qWarning() << "Failed to reload components:" << res.error();
|
||||
}
|
||||
mcVersion = m_components->getComponentVersion("net.minecraft");
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ Result<> optionalString(const QJsonObject& root, const QString& key, QString& va
|
||||
|
||||
Result<LibraryPtr> OneSixVersionFormat::libraryFromJson(ProblemContainer& problems, const QJsonObject& libObj, const QString& filename)
|
||||
{
|
||||
auto rsp = MojangVersionFormat::libraryFromJson(problems, libObj, filename);
|
||||
TRY(rsp)
|
||||
auto out = rsp.value();
|
||||
auto res = MojangVersionFormat::libraryFromJson(problems, libObj, filename);
|
||||
TRY(res)
|
||||
auto out = res.value();
|
||||
TRY(optionalString(libObj, "MMC-hint", out->m_hint))
|
||||
TRY(optionalString(libObj, "MMC-absulute_url", out->m_absoluteURL))
|
||||
TRY(optionalString(libObj, "MMC-absoluteUrl", out->m_absoluteURL))
|
||||
|
||||
@@ -222,10 +222,10 @@ Result<> loadPackProfile(PackProfile* parent, const QString& filename, Component
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
if (auto res = parse(); !res) {
|
||||
auto message = QObject::tr("Couldn't parse %1 : bad file format").arg(componentsFile.fileName());
|
||||
qCCritical(instanceProfileC) << message;
|
||||
qCWarning(instanceProfileC) << "error:" << rsp.error();
|
||||
qCWarning(instanceProfileC) << "error:" << res.error();
|
||||
container.clear();
|
||||
return std::unexpected(message);
|
||||
}
|
||||
|
||||
@@ -58,11 +58,11 @@ VersionFilePtr createErrorVersionFile(QString fileId, QString filepath, const QS
|
||||
|
||||
VersionFilePtr guardedParseJson(const QJsonDocument& doc, const QString& fileId, const QString& filepath, const bool& requireOrder)
|
||||
{
|
||||
auto rsp = OneSixVersionFormat::versionFileFromJson(doc, filepath, requireOrder);
|
||||
if (!rsp) {
|
||||
return createErrorVersionFile(fileId, filepath, rsp.error());
|
||||
auto res = OneSixVersionFormat::versionFileFromJson(doc, filepath, requireOrder);
|
||||
if (!res) {
|
||||
return createErrorVersionFile(fileId, filepath, res.error());
|
||||
}
|
||||
return rsp.value();
|
||||
return res.value();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -539,7 +539,7 @@ bool ModFolderModel::deleteResources(const QModelIndexList& indexes)
|
||||
}
|
||||
}
|
||||
};
|
||||
auto rsp = ResourceFolderModel::deleteResources(indexes);
|
||||
auto res = ResourceFolderModel::deleteResources(indexes);
|
||||
for (auto* mod : allMods()) {
|
||||
auto id = mod->mod_id();
|
||||
deleteInvalid(m_requiredBy[id]);
|
||||
@@ -551,5 +551,5 @@ bool ModFolderModel::deleteResources(const QModelIndexList& indexes)
|
||||
emit dataChanged(index(row, RequiresColumn), index(row, RequiredByColumn));
|
||||
}
|
||||
}
|
||||
return rsp;
|
||||
return res;
|
||||
}
|
||||
@@ -361,9 +361,9 @@ void SkinList::save()
|
||||
arr << s.toJSON();
|
||||
}
|
||||
doc["skins"] = arr;
|
||||
auto rsp = Json::write(doc, m_dir.absoluteFilePath("index.json"));
|
||||
if (!rsp) {
|
||||
qCritical() << "Failed to write skin index file :" << rsp.error();
|
||||
auto res = Json::write(doc, m_dir.absoluteFilePath("index.json"));
|
||||
if (!res) {
|
||||
qCritical() << "Failed to write skin index file :" << res.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -261,8 +261,8 @@ Task::Ptr EnsureMetadataTask::modrinthVersionsTask()
|
||||
m_tempVersions.insert(hash, version.value());
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qDebug() << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qDebug() << res.error();
|
||||
qDebug() << entries;
|
||||
|
||||
emitFail(resource);
|
||||
@@ -334,8 +334,8 @@ Task::Ptr EnsureMetadataTask::modrinthProjectsTask()
|
||||
updateMetadata(pack, m_tempVersions.find(hash).value(), resource);
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qWarning() << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qWarning() << res.error();
|
||||
qWarning() << *doc;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -173,8 +173,8 @@ Task::Ptr ResourceAPI::getProjectInfo(const ProjectInfoArgs& args,
|
||||
|
||||
return loadExtraPackInfo(*pack, obj);
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qWarning() << "Error while reading" << debugName() << "resource info:" << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qWarning() << "Error while reading" << debugName() << "resource info:" << res.error();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,8 @@ void Flame::FileResolvingTask::netJobFinished(QByteArray* response)
|
||||
qDebug() << "Found alternative on modrinth" << out.version.fileName;
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qDebug() << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qDebug() << res.error();
|
||||
qDebug() << entries;
|
||||
continue;
|
||||
}
|
||||
@@ -204,9 +204,7 @@ void Flame::FileResolvingTask::getFlameProjects()
|
||||
|
||||
auto stepProgress2 = std::make_shared<TaskStepProgress>();
|
||||
connect(m_task.get(), &Task::succeeded, this, [this, response, stepProgress2] {
|
||||
auto doc = Json::requireObject(*response).and_then([](const auto& v) {
|
||||
return Json::requireArray(v, "data");
|
||||
});
|
||||
auto doc = Json::requireObject(*response).and_then([](const auto& v) { return Json::requireArray(v, "data"); });
|
||||
if (!doc) {
|
||||
qWarning() << "Error while parsing CurseForge projects response:" << doc.error();
|
||||
qWarning() << *response;
|
||||
|
||||
@@ -213,9 +213,7 @@ QList<ModPlatform::Category> FlameAPI::loadModCategories(const QByteArray& respo
|
||||
{
|
||||
QList<ModPlatform::Category> categories;
|
||||
auto parse = [&response, &categories] -> Result<> {
|
||||
auto doc = Json::requireObject(response).and_then([](const auto& v) {
|
||||
return Json::requireArray(v, "data");
|
||||
});
|
||||
auto doc = Json::requireObject(response).and_then([](const auto& v) { return Json::requireArray(v, "data"); });
|
||||
TRY(doc)
|
||||
|
||||
for (auto val : doc.value()) {
|
||||
@@ -229,8 +227,8 @@ QList<ModPlatform::Category> FlameAPI::loadModCategories(const QByteArray& respo
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qCritical() << "Failed to parse response from categories:" << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qCritical() << "Failed to parse response from categories:" << res.error();
|
||||
qDebug() << response;
|
||||
}
|
||||
return categories;
|
||||
|
||||
@@ -75,8 +75,8 @@ void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, QByteArray*
|
||||
TRY(arr)
|
||||
return FlameMod::loadIndexedPackVersions(*pack.get(), arr.value());
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qWarning() << "Error while parsing JSON response from latest mod version:" << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qWarning() << "Error while parsing JSON response from latest mod version:" << res.error();
|
||||
qWarning() << *response;
|
||||
return;
|
||||
}
|
||||
@@ -175,15 +175,15 @@ void FlameCheckUpdate::collectBlockedMods()
|
||||
setStatus(tr("Parsing API response from CurseForge for '%1'...").arg(resource->name()));
|
||||
|
||||
ModPlatform::IndexedPack pack;
|
||||
auto rsp = FlameMod::loadIndexedPack(pack, entryObj.value());
|
||||
TRY(rsp)
|
||||
auto res = FlameMod::loadIndexedPack(pack, entryObj.value());
|
||||
TRY(res)
|
||||
auto recoverUrl = QString("%1/download/%2").arg(pack.websiteUrl, m_blocked[resource]);
|
||||
emit checkFailed(resource, tr("Resource has a new update available, but is not downloadable using CurseForge."),
|
||||
recoverUrl);
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qDebug() << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qDebug() << res.error();
|
||||
qDebug() << *doc;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -164,9 +164,9 @@ void FlameCreationTask::executeTask()
|
||||
|
||||
if (oldIndexFile.exists()) {
|
||||
Flame::Manifest oldPack;
|
||||
auto rsp = Flame::loadManifest(oldPack, oldIndexPath);
|
||||
if (!rsp) {
|
||||
qWarning() << "Error while parsing old manifest: " << rsp.error();
|
||||
auto res = Flame::loadManifest(oldPack, oldIndexPath);
|
||||
if (!res) {
|
||||
qWarning() << "Error while parsing old manifest: " << res.error();
|
||||
}
|
||||
|
||||
auto oldFiles = oldPack.files;
|
||||
@@ -247,8 +247,8 @@ void FlameCreationTask::executeTask()
|
||||
oldFiles.insert(id.value(), file);
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qCritical() << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qCritical() << res.error();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -381,9 +381,9 @@ void FlameCreationTask::createInstance()
|
||||
|
||||
const QString indexPath(FS::PathCombine(m_stagingPath, "manifest.json"));
|
||||
if (!m_pack.isLoaded) {
|
||||
auto rsp = Flame::loadManifest(m_pack, indexPath);
|
||||
if (!rsp) {
|
||||
emitFailed(tr("Could not understand pack manifest:\n") + rsp.error());
|
||||
auto res = Flame::loadManifest(m_pack, indexPath);
|
||||
if (!res) {
|
||||
emitFailed(tr("Could not understand pack manifest:\n") + res.error());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,8 +222,8 @@ void FlamePackExportTask::makeApiRequest()
|
||||
{ .addonId = modid.value(), .version = id.value(), .enabled = mod->enabled, .isMod = mod->isMod });
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qDebug() << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qDebug() << res.error();
|
||||
qDebug() << *doc;
|
||||
break;
|
||||
}
|
||||
@@ -306,8 +306,8 @@ void FlamePackExportTask::getProjectsInfo()
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qDebug() << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qDebug() << res.error();
|
||||
qDebug() << *doc;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ Result<Modpack> parseDirectory(const QString& path)
|
||||
}
|
||||
}
|
||||
if (!modpack.loaderType.has_value()) {
|
||||
if (auto rsp = legacyInstanceParsing(path, &modpack.loaderType, &modpack.loaderVersion); !rsp) {
|
||||
qDebug() << rsp.error();
|
||||
if (auto res = legacyInstanceParsing(path, &modpack.loaderType, &modpack.loaderVersion); !res) {
|
||||
qDebug() << res.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,13 +43,13 @@ namespace LegacyFTB {
|
||||
|
||||
void PrivatePackManager::load()
|
||||
{
|
||||
auto rsp = FS::read(m_filename);
|
||||
if (!rsp) {
|
||||
auto res = FS::read(m_filename);
|
||||
if (!res) {
|
||||
currentPacks = {};
|
||||
qWarning() << "Failed to read third party FTB pack codes from" << m_filename;
|
||||
return;
|
||||
}
|
||||
auto foo = QString::fromUtf8(rsp.value()).split('\n', Qt::SkipEmptyParts);
|
||||
auto foo = QString::fromUtf8(res.value()).split('\n', Qt::SkipEmptyParts);
|
||||
currentPacks = QSet<QString>(foo.begin(), foo.end());
|
||||
|
||||
dirty = false;
|
||||
@@ -61,8 +61,8 @@ void PrivatePackManager::save() const
|
||||
return;
|
||||
}
|
||||
QStringList list = currentPacks.values();
|
||||
auto rsp = FS::write(m_filename, list.join('\n').toUtf8());
|
||||
if (!rsp) {
|
||||
auto res = FS::write(m_filename, list.join('\n').toUtf8());
|
||||
if (!res) {
|
||||
qWarning() << "Failed to write third party FTB pack codes to" << m_filename;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,8 +184,8 @@ QList<ModPlatform::Category> ModrinthAPI::loadCategories(const QByteArray& respo
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qWarning() << "Error while parsing JSON response from categories:" << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qWarning() << "Error while parsing JSON response from categories:" << res.error();
|
||||
qWarning() << response;
|
||||
}
|
||||
return categories;
|
||||
|
||||
@@ -412,8 +412,8 @@ bool ModrinthCreationTask::parseManifest(const QString& indexPath, std::vector<F
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
emitFailed(tr("Could not understand pack index:\n") + rsp.error());
|
||||
if (auto res = parse(); !res) {
|
||||
emitFailed(tr("Could not understand pack index:\n") + res.error());
|
||||
return false;
|
||||
}
|
||||
if (!optionalFiles.empty()) {
|
||||
|
||||
@@ -321,8 +321,8 @@ void HttpMetaCache::SaveNow()
|
||||
}
|
||||
toplevel.insert("entries", entriesArr);
|
||||
|
||||
auto rsp = Json::write(toplevel, m_index_file);
|
||||
if (!rsp) {
|
||||
qCWarning(taskHttpMetaCacheLogC) << "Error writing cache:" << rsp.error();
|
||||
auto res = Json::write(toplevel, m_index_file);
|
||||
if (!res) {
|
||||
qCWarning(taskHttpMetaCacheLogC) << "Error writing cache:" << res.error();
|
||||
}
|
||||
}
|
||||
@@ -227,10 +227,10 @@ namespace {
|
||||
void readIndex(const QString& path, QMap<QString, Language>& languages)
|
||||
{
|
||||
auto parse = [&languages, &path] -> Result<> {
|
||||
auto rsp = Json::requireObject(path);
|
||||
TRY(rsp)
|
||||
auto res = Json::requireObject(path);
|
||||
TRY(res)
|
||||
|
||||
const auto& doc = rsp.value();
|
||||
const auto& doc = res.value();
|
||||
auto fileType = Json::requireString(doc, "file_type");
|
||||
TRY(fileType)
|
||||
if (fileType.value() != "MMC-TRANSLATION-INDEX") {
|
||||
@@ -258,8 +258,8 @@ void readIndex(const QString& path, QMap<QString, Language>& languages)
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qCritical() << "Translations Download Failed:" << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qCritical() << "Translations Download Failed:" << res.error();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -89,9 +89,9 @@ bool GuiUtil::isUploadCanceled(const Result<QString>& result)
|
||||
|
||||
Result<QString> GuiUtil::uploadPaste(const QString& name, const QFileInfo& filePath, QWidget* parentWidget)
|
||||
{
|
||||
auto rsp = FS::read(filePath.absoluteFilePath());
|
||||
TRY(rsp)
|
||||
return uploadPaste(name, rsp.value(), parentWidget);
|
||||
auto res = FS::read(filePath.absoluteFilePath());
|
||||
TRY(res)
|
||||
return uploadPaste(name, res.value(), parentWidget);
|
||||
};
|
||||
|
||||
Result<QString> GuiUtil::uploadPaste(const QString& name, const QString& data, QWidget* parentWidget)
|
||||
|
||||
@@ -169,9 +169,9 @@ void ExportToModListDialog::done(int result)
|
||||
return;
|
||||
}
|
||||
|
||||
auto rsp = FS::write(output, ui->finalText->toPlainText().toUtf8());
|
||||
if (!rsp) {
|
||||
qCritical() << "Failed to save mod list file :" << rsp.error();
|
||||
auto res = FS::write(output, ui->finalText->toPlainText().toUtf8());
|
||||
if (!res) {
|
||||
qCritical() << "Failed to save mod list file :" << res.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,12 +122,12 @@ void McClient::readRawResponse()
|
||||
|
||||
m_resp.append(m_socket.readAll());
|
||||
if (m_responseReadState == ResponseReadState::Waiting && m_resp.size() >= 5) {
|
||||
auto rsp = readVarInt(m_resp);
|
||||
if (!rsp) {
|
||||
emitFail(rsp.error());
|
||||
auto res = readVarInt(m_resp);
|
||||
if (!res) {
|
||||
emitFail(res.error());
|
||||
return;
|
||||
}
|
||||
m_wantedRespLength = *rsp;
|
||||
m_wantedRespLength = *res;
|
||||
m_responseReadState = ResponseReadState::GotLength;
|
||||
}
|
||||
|
||||
|
||||
@@ -365,8 +365,8 @@ CoreModFolderPage::CoreModFolderPage(MinecraftInstance* inst, ModFolderModel* mo
|
||||
if ((version != nullptr) && version->getComponent("net.minecraftforge") && version->getComponent("net.minecraft")) {
|
||||
auto minecraftCmp = version->getComponent("net.minecraft");
|
||||
if (!minecraftCmp->m_loaded) {
|
||||
if (auto rsp = version->reload(Net::Mode::Offline); !rsp) {
|
||||
qWarning() << "Failed to reload components:" << rsp.error();
|
||||
if (auto res = version->reload(Net::Mode::Offline); !res) {
|
||||
qWarning() << "Failed to reload components:" << res.error();
|
||||
}
|
||||
auto update = version->getCurrentTask();
|
||||
if (update) {
|
||||
|
||||
@@ -355,9 +355,9 @@ void OtherLogsPage::reload()
|
||||
void OtherLogsPage::on_btnPaste_clicked()
|
||||
{
|
||||
QString name = m_currentFile.isEmpty() ? displayName() : m_currentFile;
|
||||
auto rsp = GuiUtil::uploadPaste(name, ui->text->toPlainText(), this);
|
||||
if (!rsp && !GuiUtil::isUploadCanceled(rsp)) {
|
||||
qWarning() << "Log upload failed:" << rsp.error();
|
||||
auto res = GuiUtil::uploadPaste(name, ui->text->toPlainText(), this);
|
||||
if (!res && !GuiUtil::isUploadCanceled(res)) {
|
||||
qWarning() << "Log upload failed:" << res.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
namespace {
|
||||
unsigned getOnlinePlayers(const QJsonObject& data)
|
||||
{
|
||||
auto rsp = Json::requireObject(data, "players").and_then([](const auto& v) { return Json::requireInteger(v, "online"); });
|
||||
if (!rsp) {
|
||||
qWarning() << "server ping failed to parse response" << rsp.error();
|
||||
auto res = Json::requireObject(data, "players").and_then([](const auto& v) { return Json::requireInteger(v, "online"); });
|
||||
if (!res) {
|
||||
qWarning() << "server ping failed to parse response" << res.error();
|
||||
return 0;
|
||||
}
|
||||
return rsp.value();
|
||||
return res.value();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -118,11 +118,11 @@ struct Server {
|
||||
static std::unique_ptr<nbt::tag_compound> parseServersDat(const QString& filename)
|
||||
{
|
||||
try {
|
||||
auto rsp = FS::read(filename);
|
||||
if (!rsp) {
|
||||
auto res = FS::read(filename);
|
||||
if (!res) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto& input = rsp.value();
|
||||
const auto& input = res.value();
|
||||
std::istringstream foo(std::string(input.constData(), input.size()));
|
||||
auto pair = nbt::io::read_compound(foo);
|
||||
|
||||
@@ -149,8 +149,8 @@ static bool serializeServerDat(const QString& filename, nbt::tag_compound* level
|
||||
std::ostringstream s;
|
||||
nbt::io::write_tag("", *levelInfo, s);
|
||||
QByteArray val(s.str().data(), (int)s.str().size());
|
||||
auto rsp = FS::write(filename, val);
|
||||
return rsp.has_value();
|
||||
auto res = FS::write(filename, val);
|
||||
return res.has_value();
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -238,8 +238,8 @@ void Technic::ListModel::searchRequestFinished(QByteArray* responsePtr)
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (auto rsp = parse(); !rsp) {
|
||||
qCritical() << "Couldn't parse technic search results:" << rsp.error();
|
||||
if (auto res = parse(); !res) {
|
||||
qCritical() << "Couldn't parse technic search results:" << res.error();
|
||||
return;
|
||||
}
|
||||
searchState = Finished;
|
||||
|
||||
@@ -65,9 +65,9 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest
|
||||
m_palette = baseTheme->colorScheme();
|
||||
|
||||
bool hasCustomLogColors = false;
|
||||
auto rsp = read(themeFilePath, hasCustomLogColors);
|
||||
if (!rsp) {
|
||||
themeWarningLog() << "Couldn't read theme json:" << rsp.error();
|
||||
auto res = read(themeFilePath, hasCustomLogColors);
|
||||
if (!res) {
|
||||
themeWarningLog() << "Couldn't read theme json:" << res.error();
|
||||
m_logColors = defaultLogColors(m_palette);
|
||||
m_styleSheet = baseTheme->appStyleSheet();
|
||||
} else {
|
||||
@@ -109,12 +109,12 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest
|
||||
|
||||
m_palette = baseTheme->colorScheme();
|
||||
// TODO: validate qss?
|
||||
auto rsp = FS::read(path);
|
||||
if (!rsp) {
|
||||
themeWarningLog() << "Couldn't load qss:" << rsp.error() << "from" << path;
|
||||
auto res = FS::read(path);
|
||||
if (!res) {
|
||||
themeWarningLog() << "Couldn't load qss:" << res.error() << "from" << path;
|
||||
m_styleSheet = baseTheme->appStyleSheet();
|
||||
} else {
|
||||
m_styleSheet = QString::fromUtf8(rsp.value());
|
||||
m_styleSheet = QString::fromUtf8(res.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,11 +355,11 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar
|
||||
auto markerFilePath = QDir(m_rootPath).absoluteFilePath(".prism_launcher_updater_unpack.marker");
|
||||
auto markerFile = QFileInfo(markerFilePath);
|
||||
if (markerFile.exists()) {
|
||||
auto rsp = FS::read(markerFilePath);
|
||||
if (!rsp) {
|
||||
unrecoverable("Could not read updater marker file: " + rsp.error());
|
||||
auto res = FS::read(markerFilePath);
|
||||
if (!res) {
|
||||
unrecoverable("Could not read updater marker file: " + res.error());
|
||||
}
|
||||
auto targetDir = QString(rsp.value()).trimmed();
|
||||
auto targetDir = QString(res.value()).trimmed();
|
||||
if (targetDir.isEmpty()) {
|
||||
qWarning() << "Empty updater marker file contains no install target. making best guess of parent dir";
|
||||
targetDir = QDir(m_rootPath).absoluteFilePath("..");
|
||||
@@ -515,11 +515,11 @@ void PrismUpdaterApp::moveAndFinishUpdate(QDir target)
|
||||
if (manifest.isFile()) {
|
||||
// load manifest from file
|
||||
logUpdate(tr("Reading manifest from %1").arg(manifest.absoluteFilePath()));
|
||||
auto rsp = FS::read(manifest.absoluteFilePath());
|
||||
if (!rsp) {
|
||||
logUpdate(tr("Could not read manifest: %1").arg(rsp.error()));
|
||||
auto res = FS::read(manifest.absoluteFilePath());
|
||||
if (!res) {
|
||||
logUpdate(tr("Could not read manifest: %1").arg(res.error()));
|
||||
} else {
|
||||
auto contents = QString::fromUtf8(rsp.value());
|
||||
auto contents = QString::fromUtf8(res.value());
|
||||
auto files = contents.split('\n');
|
||||
for (const auto& file : files) {
|
||||
fileList.append(file.trimmed());
|
||||
@@ -812,19 +812,19 @@ void PrismUpdaterApp::clearUpdateLog()
|
||||
void PrismUpdaterApp::logUpdate(const QString& msg)
|
||||
{
|
||||
qDebug() << qUtf8Printable(msg);
|
||||
auto rsp = FS::append(m_updateLogPath, QStringLiteral("%1\n").arg(msg).toUtf8());
|
||||
if (!rsp) {
|
||||
qWarning() << "Failed to write update log:" << rsp.error();
|
||||
auto res = FS::append(m_updateLogPath, QStringLiteral("%1\n").arg(msg).toUtf8());
|
||||
if (!res) {
|
||||
qWarning() << "Failed to write update log:" << res.error();
|
||||
}
|
||||
}
|
||||
|
||||
std::tuple<QDateTime, QString, QString, QString, QString> read_lock_File(const QString& path)
|
||||
{
|
||||
auto rsp = FS::read(path);
|
||||
if (!rsp) {
|
||||
unrecoverable("Could not read lock file: " + rsp.error());
|
||||
auto res = FS::read(path);
|
||||
if (!res) {
|
||||
unrecoverable("Could not read lock file: " + res.error());
|
||||
}
|
||||
auto contents = QString(rsp.value());
|
||||
auto contents = QString(res.value());
|
||||
auto lines = contents.split('\n');
|
||||
|
||||
QDateTime timestamp;
|
||||
@@ -853,15 +853,15 @@ std::tuple<QDateTime, QString, QString, QString, QString> read_lock_File(const Q
|
||||
|
||||
bool write_lock_file(const QString& path, QDateTime timestamp, QString from, QString to, QString target, QString data_path)
|
||||
{
|
||||
auto rsp = FS::write(path, QStringLiteral("TIMESTAMP=%1\nFROM=%2\nTO=%3\nTARGET=%4\nDATA_PATH=%5\n")
|
||||
auto res = FS::write(path, QStringLiteral("TIMESTAMP=%1\nFROM=%2\nTO=%3\nTARGET=%4\nDATA_PATH=%5\n")
|
||||
.arg(timestamp.toString(Qt::ISODate))
|
||||
.arg(from)
|
||||
.arg(to)
|
||||
.arg(target)
|
||||
.arg(data_path)
|
||||
.toUtf8());
|
||||
if (!rsp) {
|
||||
qWarning() << "Error writing lockfile:" << rsp.error();
|
||||
if (!res) {
|
||||
qWarning() << "Error writing lockfile:" << res.error();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -912,8 +912,8 @@ void PrismUpdaterApp::performInstall(QFileInfo file)
|
||||
clearUpdateLog();
|
||||
|
||||
auto changelogPath = FS::PathCombine(m_dataPath, ".prism_launcher_update.changelog");
|
||||
if (auto rsp = FS::write(changelogPath, m_install_release.body.toUtf8()); !rsp) {
|
||||
logUpdate(tr("Failed to write changelog: %1").arg(rsp.error()));
|
||||
if (auto res = FS::write(changelogPath, m_install_release.body.toUtf8()); !res) {
|
||||
logUpdate(tr("Failed to write changelog: %1").arg(res.error()));
|
||||
}
|
||||
|
||||
logUpdate(tr("Updating from %1 to %2").arg(m_prismVersion).arg(m_install_release.tag_name));
|
||||
@@ -943,8 +943,8 @@ void PrismUpdaterApp::unpackAndInstall(QFileInfo archive)
|
||||
|
||||
if (auto loc = unpackArchive(archive)) {
|
||||
auto markerFilePath = loc.value().absoluteFilePath(".prism_launcher_updater_unpack.marker");
|
||||
if (auto rsp = FS::write(markerFilePath, m_rootPath.toUtf8()); !rsp) {
|
||||
unrecoverable("Failed to write unpack marker: " + rsp.error());
|
||||
if (auto res = FS::write(markerFilePath, m_rootPath.toUtf8()); !res) {
|
||||
unrecoverable("Failed to write unpack marker: " + res.error());
|
||||
}
|
||||
|
||||
QProcess proc = QProcess();
|
||||
@@ -981,11 +981,11 @@ void PrismUpdaterApp::backupAppDir()
|
||||
// load manifest from file
|
||||
|
||||
logUpdate(tr("Reading manifest from %1").arg(manifest.absoluteFilePath()));
|
||||
auto rsp = FS::read(manifest.absoluteFilePath());
|
||||
if (!rsp) {
|
||||
logUpdate(tr("Could not read manifest: %1").arg(rsp.error()));
|
||||
auto res = FS::read(manifest.absoluteFilePath());
|
||||
if (!res) {
|
||||
logUpdate(tr("Could not read manifest: %1").arg(res.error()));
|
||||
} else {
|
||||
auto contents = QString::fromUtf8(rsp.value());
|
||||
auto contents = QString::fromUtf8(res.value());
|
||||
auto files = contents.split('\n');
|
||||
for (const auto& file : files) {
|
||||
file_list.append(file.trimmed());
|
||||
@@ -1023,8 +1023,8 @@ void PrismUpdaterApp::backupAppDir()
|
||||
QStringLiteral("backup_") + QString(m_prismVersion).replace(s_replaceRegex, QString("_")) + "-" + m_prismGitCommit);
|
||||
FS::ensureFolderPathExists(backup_dir);
|
||||
auto backup_marker_path = FS::PathCombine(m_dataPath, ".prism_launcher_update_backup_path.txt");
|
||||
if (auto rsp = FS::write(backup_marker_path, backup_dir.toUtf8()); !rsp) {
|
||||
unrecoverable("Failed to write backup marker: " + rsp.error());
|
||||
if (auto res = FS::write(backup_marker_path, backup_dir.toUtf8()); !res) {
|
||||
unrecoverable("Failed to write backup marker: " + res.error());
|
||||
}
|
||||
|
||||
QProgressDialog progress(tr("Backing up install at %1").arg(m_rootPath), "", 0, file_list.length());
|
||||
|
||||
Reference in new issue
Block a user