From a23323a01ee2713209619ad99d8859616aa99cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 7 Jul 2013 18:12:09 +0200 Subject: [PATCH] Small tweaks to the assets - delete extra files --- asset_test.cpp | 44 +++++++++++++++++++++---------- libmultimc/src/gameupdatetask.cpp | 8 +++++- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/asset_test.cpp b/asset_test.cpp index fb797b97..90da314f 100644 --- a/asset_test.cpp +++ b/asset_test.cpp @@ -13,19 +13,11 @@ inline QDomElement getDomElementByTagName(QDomElement parent, QString tagname) return QDomElement(); } -// a job that removes all files from the base folder that don't match the whitelist -// runs in whatever thread owns the queue. it is fast though. -class NukeAndPaveJob: public Job +class ThreadedDeleter : public QThread { + Q_OBJECT public: - explicit NukeAndPaveJob(QString base, QStringList whitelist) - :Job() - { - QDir dir(base); - m_base = dir.absolutePath(); - m_whitelist = whitelist; - }; - virtual void start() + void run() { QDirIterator iter(m_base, QDirIterator::Subdirectories); QStringList nuke_list; @@ -51,13 +43,37 @@ public: f.remove(); } } - emit finish(); }; -private: QString m_base; QStringList m_whitelist; }; +class NukeAndPaveJob: public Job +{ + Q_OBJECT +public: + + explicit NukeAndPaveJob(QString base, QStringList whitelist) + :Job() + { + QDir dir(base); + deleterThread.m_base = dir.absolutePath(); + deleterThread.m_whitelist = whitelist; + }; +public slots: + virtual void start() + { + connect(&deleterThread, SIGNAL(finished()), SLOT(threadFinished())); + deleterThread.start(); + }; + void threadFinished() + { + emit finish(); + } +private: + ThreadedDeleter deleterThread; +}; + class DlMachine : public QObject { Q_OBJECT @@ -84,7 +100,7 @@ public slots: qDebug() << "Failed to process s3.amazonaws.com/Minecraft.Resources. XML error:" << xmlErrorMsg << ba; } - QRegExp etag_match(".*([a-f0-9]{32}).*"); + //QRegExp etag_match(".*([a-f0-9]{32}).*"); QDomNodeList contents = doc.elementsByTagName("Contents"); JobList *job = new JobList(); diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp index c718ce71..49f9335f 100644 --- a/libmultimc/src/gameupdatetask.cpp +++ b/libmultimc/src/gameupdatetask.cpp @@ -47,7 +47,13 @@ void GameUpdateTask::executeTask() // Get a pointer to the version object that corresponds to the instance's version. MinecraftVersion *targetVersion = (MinecraftVersion *)MinecraftVersionList::getMainList(). findVersion(m_inst->intendedVersion()); - Q_ASSERT_X(targetVersion != NULL, "game update", "instance's intended version is not an actual version"); + if(targetVersion == NULL) + { + //Q_ASSERT_X(targetVersion != NULL, "game update", "instance's intended version is not an actual version"); + setState(StateFinished); + emit gameUpdateComplete(m_response); + return; + } // Make directories QDir binDir(m_inst->binDir());