code quality cleanup
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
d2f3dbaa29
commit
fda2c116be
@ -167,7 +167,7 @@ bool ensureFolderPathExists(QString foldernamepath)
|
|||||||
/// @param src srouce file path
|
/// @param src srouce file path
|
||||||
/// @param dst destination file path
|
/// @param dst destination file path
|
||||||
/// @return boolean: was there an error during the filecopy?
|
/// @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;
|
using copy_opts = fs::copy_options;
|
||||||
|
|
||||||
std::error_code err;
|
std::error_code err;
|
||||||
|
@ -75,7 +75,7 @@ bool ensureFilePathExists(QString filenamepath);
|
|||||||
*/
|
*/
|
||||||
bool ensureFolderPathExists(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
|
/// @brief Copies a directory and it's contents from src to dest
|
||||||
class copy {
|
class copy {
|
||||||
|
@ -413,31 +413,32 @@ void FlameCreationTask::idResolverSucceeded(QEventLoop& loop)
|
|||||||
|
|
||||||
/// @brief copy the matched blocked mods to the instance staging area
|
/// @brief copy the matched blocked mods to the instance staging area
|
||||||
/// @param blocked_mods list of the blocked mods and their matched paths
|
/// @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..."));
|
setStatus(tr("Copying Blocked Mods..."));
|
||||||
setAbortable(false);
|
setAbortable(false);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int total = blocked_mods.length();
|
int total = blocked_mods.length();
|
||||||
setProgress(i, total);
|
setProgress(i, total);
|
||||||
for (auto mod = blocked_mods.begin(); mod != blocked_mods.end(); mod++, i++) {
|
for (auto &mod : blocked_mods) {
|
||||||
|
|
||||||
if (!mod->matched) {
|
if (!mod.matched) {
|
||||||
qDebug() << mod->name << "was not matched to a local file, skipping copy";
|
qDebug() << mod.name << "was not matched to a local file, skipping copy";
|
||||||
continue;
|
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)));
|
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)) {
|
if (!FS::copyFile(mod.localPath, dest_path)) { // FIXME: use FS::copy once #333 is merged
|
||||||
qDebug() << "Copy of" << mod->localPath << "to" << dest_path << "Failed";
|
qDebug() << "Copy of" << mod.localPath << "to" << dest_path << "Failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgress(i+1, total);
|
i++;
|
||||||
|
setProgress(i, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAbortable(true);
|
setAbortable(true);
|
||||||
@ -488,9 +489,7 @@ void FlameCreationTask::setupDownloadJob(QEventLoop& loop)
|
|||||||
m_files_job.reset();
|
m_files_job.reset();
|
||||||
setError(reason);
|
setError(reason);
|
||||||
});
|
});
|
||||||
connect(m_files_job.get(), &NetJob::progress, [&](qint64 current, qint64 total) {
|
connect(m_files_job.get(), &NetJob::progress, this, &FlameCreationTask::setProgress);
|
||||||
setProgress(current, total);
|
|
||||||
});
|
|
||||||
connect(m_files_job.get(), &NetJob::finished, &loop, &QEventLoop::quit);
|
connect(m_files_job.get(), &NetJob::finished, &loop, &QEventLoop::quit);
|
||||||
|
|
||||||
setStatus(tr("Downloading mods..."));
|
setStatus(tr("Downloading mods..."));
|
||||||
|
@ -31,7 +31,7 @@ class FlameCreationTask final : public InstanceCreationTask {
|
|||||||
private slots:
|
private slots:
|
||||||
void idResolverSucceeded(QEventLoop&);
|
void idResolverSucceeded(QEventLoop&);
|
||||||
void setupDownloadJob(QEventLoop&);
|
void setupDownloadJob(QEventLoop&);
|
||||||
void copyBlockedMods(QList<BlockedMod> blocked_mods);
|
void copyBlockedMods(QList<BlockedMod> const& blocked_mods);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* m_parent = nullptr;
|
QWidget* m_parent = nullptr;
|
||||||
|
@ -326,7 +326,7 @@ void PackInstallTask::downloadPack()
|
|||||||
void PackInstallTask::onModDownloadSucceeded()
|
void PackInstallTask::onModDownloadSucceeded()
|
||||||
{
|
{
|
||||||
m_net_job.reset();
|
m_net_job.reset();
|
||||||
if (m_blocked_mods.length() > 0) {
|
if (!m_blocked_mods.isEmpty()) {
|
||||||
copyBlockedMods();
|
copyBlockedMods();
|
||||||
}
|
}
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
|
Loading…
Reference in New Issue
Block a user