Log error if file open/commit fails (#5235)

This commit is contained in:
Alexandru Ionut Tripon 2026-03-23 13:11:39 +00:00 committed by GitHub
commit f91accdce8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 54 additions and 44 deletions

View file

@ -618,7 +618,7 @@ bool PackInstallTask::createPackComponent(QString instanceRoot, PackProfile* pro
QFile file(patchFileName);
if (!file.open(QFile::WriteOnly)) {
qCritical() << "Error opening" << file.fileName() << "for reading:" << file.errorString();
qCritical() << "Error opening" << file.fileName() << "for writing:" << file.errorString();
return false;
}
file.write(OneSixVersionFormat::versionFileToJson(f).toJson());

View file

@ -16,7 +16,7 @@ void createOverrides(const QString& name, const QString& parent_folder, const QS
QFile file(file_path);
if (!file.open(QFile::WriteOnly)) {
qWarning() << "Failed to open file '" << file.fileName() << "' for writing!";
qWarning() << "Failed to open file" << file.fileName() << "for writing:" << file.errorString();
return;
}
@ -47,7 +47,7 @@ QStringList readOverrides(const QString& name, const QString& parent_folder)
QStringList previous_overrides;
if (!file.open(QFile::ReadOnly)) {
qWarning() << "Failed to open file '" << file.fileName() << "' for reading!";
qWarning() << "Failed to open file" << file.fileName() << "for reading:" << file.errorString();
return previous_overrides;
}

View file

@ -169,7 +169,7 @@ void PackInstallTask::install()
break;
}
} else {
qWarning() << "Failed to open file '" << packJson.fileName() << "' for reading!";
qWarning() << "Failed to open file" << packJson.fileName() << "for reading:" << packJson.errorString();
}
}

View file

@ -108,13 +108,13 @@ void ModrinthPackExportTask::collectHashes()
QFile openFile(file.absoluteFilePath());
if (!openFile.open(QFile::ReadOnly)) {
qWarning() << "Could not open" << file << "for hashing";
qWarning() << "Could not open" << file << "for hashing:" << openFile.errorString();
continue;
}
const QByteArray data = openFile.readAll();
if (openFile.error() != QFileDevice::NoError) {
qWarning() << "Could not read" << file;
qWarning() << "Could not read" << file << "error:" << openFile.errorString();
continue;
}
auto sha512 = Hashing::hash(data, Hashing::Algorithm::Sha512);

View file

@ -190,7 +190,7 @@ void V1::updateModIndex(const QDir& index_dir, Mod& mod)
}
if (!index_file.open(QIODevice::ReadWrite)) {
qCritical() << QString("Could not open file %1!").arg(normalized_fname);
qCritical() << "Could not open file" << normalized_fname << "error:" << index_file.errorString();
return;
}

View file

@ -117,7 +117,7 @@ void Technic::TechnicPackProcessor::run(SettingsObject* globalSettings,
} else if (QFile::exists(versionJson)) {
QFile file(versionJson);
if (!file.open(QIODevice::ReadOnly)) {
emit failed(tr("Unable to open \"version.json\"!"));
emit failed(tr("Unable to open \"version.json\": %1").arg(file.errorString()));
return;
}
data = file.readAll();