diff options
author | TakSuyu <taksuyu@gmail.com> | 2013-07-27 12:55:51 -0700 |
---|---|---|
committer | TakSuyu <taksuyu@gmail.com> | 2013-07-27 12:55:51 -0700 |
commit | dc39d093396c9a0ed4f03d81f95fcc8fa5705b65 (patch) | |
tree | b88bf5fa692de82ce3418bdf5c55e9cd9eff37bc /asset_test.cpp | |
parent | 44498f98945b7501486da35c5fdc32f94a2be080 (diff) | |
parent | a7a84d4dbb58565f108cb0886da6cb786e34d10d (diff) | |
download | MultiMC-dc39d093396c9a0ed4f03d81f95fcc8fa5705b65.tar MultiMC-dc39d093396c9a0ed4f03d81f95fcc8fa5705b65.tar.gz MultiMC-dc39d093396c9a0ed4f03d81f95fcc8fa5705b65.tar.lz MultiMC-dc39d093396c9a0ed4f03d81f95fcc8fa5705b65.tar.xz MultiMC-dc39d093396c9a0ed4f03d81f95fcc8fa5705b65.zip |
Merge remote-tracking branch 'upstream/master'
Conflicts:
gui/mainwindow.cpp
Diffstat (limited to 'asset_test.cpp')
-rw-r--r-- | asset_test.cpp | 44 |
1 files changed, 30 insertions, 14 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(); |