code quality cleanup

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2022-10-30 22:42:35 -07:00
parent d2f3dbaa29
commit fda2c116be
5 changed files with 15 additions and 16 deletions

View File

@ -167,7 +167,7 @@ bool ensureFolderPathExists(QString foldernamepath)
/// @param src srouce file path
/// @param dst destination file path
/// @return boolean: was there an error during the filecopy?
bool copyFile(QString &src, QString &dst) {
bool copyFile(QString const& src, QString const& dst) {
using copy_opts = fs::copy_options;
std::error_code err;

View File

@ -75,7 +75,7 @@ bool ensureFilePathExists(QString filenamepath);
*/
bool ensureFolderPathExists(QString filenamepath);
bool copyFile(QString &src, QString &dst);
bool copyFile(QString const& src, QString const& dst);
/// @brief Copies a directory and it's contents from src to dest
class copy {

View File

@ -413,31 +413,32 @@ void FlameCreationTask::idResolverSucceeded(QEventLoop& loop)
/// @brief copy the matched blocked mods to the instance staging area
/// @param blocked_mods list of the blocked mods and their matched paths
void FlameCreationTask::copyBlockedMods(QList<BlockedMod> blocked_mods) {
void FlameCreationTask::copyBlockedMods(QList<BlockedMod> const& blocked_mods) {
setStatus(tr("Copying Blocked Mods..."));
setAbortable(false);
int i = 0;
int total = blocked_mods.length();
setProgress(i, total);
for (auto mod = blocked_mods.begin(); mod != blocked_mods.end(); mod++, i++) {
for (auto &mod : blocked_mods) {
if (!mod->matched) {
qDebug() << mod->name << "was not matched to a local file, skipping copy";
if (!mod.matched) {
qDebug() << mod.name << "was not matched to a local file, skipping copy";
continue;
}
auto dest_path = FS::PathCombine(m_stagingPath, "minecraft", "mods", mod->name);
auto dest_path = FS::PathCombine(m_stagingPath, "minecraft", "mods", mod.name);
setStatus(tr("Copying Blocked Mods (%1 out of %2 are done)").arg(QString::number(i), QString::number(total)));
qDebug() << "Will try to copy" << mod->localPath << "to" << dest_path;
qDebug() << "Will try to copy" << mod.localPath << "to" << dest_path;
if (!FS::copyFile(mod->localPath, dest_path)) {
qDebug() << "Copy of" << mod->localPath << "to" << dest_path << "Failed";
if (!FS::copyFile(mod.localPath, dest_path)) { // FIXME: use FS::copy once #333 is merged
qDebug() << "Copy of" << mod.localPath << "to" << dest_path << "Failed";
}
setProgress(i+1, total);
i++;
setProgress(i, total);
}
setAbortable(true);
@ -488,9 +489,7 @@ void FlameCreationTask::setupDownloadJob(QEventLoop& loop)
m_files_job.reset();
setError(reason);
});
connect(m_files_job.get(), &NetJob::progress, [&](qint64 current, qint64 total) {
setProgress(current, total);
});
connect(m_files_job.get(), &NetJob::progress, this, &FlameCreationTask::setProgress);
connect(m_files_job.get(), &NetJob::finished, &loop, &QEventLoop::quit);
setStatus(tr("Downloading mods..."));

View File

@ -31,7 +31,7 @@ class FlameCreationTask final : public InstanceCreationTask {
private slots:
void idResolverSucceeded(QEventLoop&);
void setupDownloadJob(QEventLoop&);
void copyBlockedMods(QList<BlockedMod> blocked_mods);
void copyBlockedMods(QList<BlockedMod> const& blocked_mods);
private:
QWidget* m_parent = nullptr;

View File

@ -326,7 +326,7 @@ void PackInstallTask::downloadPack()
void PackInstallTask::onModDownloadSucceeded()
{
m_net_job.reset();
if (m_blocked_mods.length() > 0) {
if (!m_blocked_mods.isEmpty()) {
copyBlockedMods();
}
emitSucceeded();