Merge pull request #397 from flowln/windows_mod_updater_fixes_maybe
Fixes https://github.com/PrismLauncher/PrismLauncher/issues/226
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <QFile>
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include <MurmurHash2.h>
|
||||
|
||||
@ -66,7 +67,7 @@ void FlameHasher::executeTask()
|
||||
// CF-specific
|
||||
auto should_filter_out = [](char c) { return (c == 9 || c == 10 || c == 13 || c == 32); };
|
||||
|
||||
std::ifstream file_stream(m_path.toStdString(), std::ifstream::binary);
|
||||
std::ifstream file_stream(StringUtils::toStdString(m_path), std::ifstream::binary);
|
||||
// TODO: This is very heavy work, but apparently QtConcurrent can't use move semantics, so we can't boop this to another thread.
|
||||
// How do we make this non-blocking then?
|
||||
m_hash = QString::number(MurmurHash2(std::move(file_stream), 4 * MiB, should_filter_out));
|
||||
|
@ -22,10 +22,14 @@
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
|
||||
#include <toml++/toml.h>
|
||||
#include "FileSystem.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "minecraft/mod/Mod.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
|
||||
#include <toml++/toml.h>
|
||||
|
||||
namespace Packwiz {
|
||||
|
||||
auto getRealIndexName(QDir& index_dir, QString normalized_fname, bool should_find_match) -> QString
|
||||
@ -63,22 +67,22 @@ static inline auto indexFileName(QString const& mod_slug) -> QString
|
||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||
|
||||
// Helper functions for extracting data from the TOML file
|
||||
auto stringEntry(toml::table table, const std::string entry_name) -> QString
|
||||
auto stringEntry(toml::table table, QString entry_name) -> QString
|
||||
{
|
||||
auto node = table[entry_name];
|
||||
auto node = table[StringUtils::toStdString(entry_name)];
|
||||
if (!node) {
|
||||
qCritical() << QString::fromStdString("Failed to read str property '" + entry_name + "' in mod metadata.");
|
||||
qCritical() << "Failed to read str property '" + entry_name + "' in mod metadata.";
|
||||
return {};
|
||||
}
|
||||
|
||||
return QString::fromStdString(node.value_or(""));
|
||||
return node.value_or("");
|
||||
}
|
||||
|
||||
auto intEntry(toml::table table, const std::string entry_name) -> int
|
||||
auto intEntry(toml::table table, QString entry_name) -> int
|
||||
{
|
||||
auto node = table[entry_name];
|
||||
auto node = table[StringUtils::toStdString(entry_name)];
|
||||
if (!node) {
|
||||
qCritical() << QString::fromStdString("Failed to read int property '" + entry_name + "' in mod metadata.");
|
||||
qCritical() << "Failed to read int property '" + entry_name + "' in mod metadata.";
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -145,6 +149,8 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
|
||||
// they want to do!
|
||||
if (index_file.exists()) {
|
||||
index_file.remove();
|
||||
} else {
|
||||
FS::ensureFilePathExists(index_file.fileName());
|
||||
}
|
||||
|
||||
if (!index_file.open(QIODevice::ReadWrite)) {
|
||||
@ -228,14 +234,14 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod
|
||||
toml::table table;
|
||||
#if TOML_EXCEPTIONS
|
||||
try {
|
||||
table = toml::parse_file(index_dir.absoluteFilePath(real_fname).toStdString());
|
||||
table = toml::parse_file(StringUtils::toStdString(index_dir.absoluteFilePath(real_fname)));
|
||||
} catch (const toml::parse_error& err) {
|
||||
qWarning() << QString("Could not open file %1!").arg(normalized_fname);
|
||||
qWarning() << "Reason: " << QString(err.what());
|
||||
return {};
|
||||
}
|
||||
#else
|
||||
table = toml::parse_file(index_dir.absoluteFilePath(real_fname).toStdString());
|
||||
table = toml::parse_file(StringUtils::toStdString(index_dir.absoluteFilePath(real_fname)));
|
||||
if (!table) {
|
||||
qWarning() << QString("Could not open file %1!").arg(normalized_fname);
|
||||
qWarning() << "Reason: " << QString(table.error().what());
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <QUrl>
|
||||
#include <QVariant>
|
||||
|
||||
struct toml_table_t;
|
||||
class QDir;
|
||||
|
||||
// Mod from launcher/minecraft/mod/Mod.h
|
||||
@ -34,9 +33,6 @@ namespace Packwiz {
|
||||
|
||||
auto getRealIndexName(QDir& index_dir, QString normalized_index_name, bool should_match = false) -> QString;
|
||||
|
||||
auto stringEntry(toml_table_t* parent, const char* entry_name) -> QString;
|
||||
auto intEntry(toml_table_t* parent, const char* entry_name) -> int;
|
||||
|
||||
class V1 {
|
||||
public:
|
||||
struct Mod {
|
||||
|
Reference in New Issue
Block a user