summaryrefslogtreecommitdiffstats
path: root/logic/OneSixUpdate.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-09-08 02:15:20 +0200
committerPetr Mrázek <peterix@gmail.com>2013-09-08 02:15:20 +0200
commit6bea4ec988b7caeac63353fb9d2a354f2fd47dad (patch)
tree77dc597c82ff3952d9f34f4ca13da1c36ca89bd8 /logic/OneSixUpdate.cpp
parent6892c11e9f287dcfb1e698f8f46233a01fb7abb6 (diff)
downloadMultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.tar
MultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.tar.gz
MultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.tar.lz
MultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.tar.xz
MultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.zip
Use HttpMetaCache to minimize network use.
Diffstat (limited to 'logic/OneSixUpdate.cpp')
-rw-r--r--logic/OneSixUpdate.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp
index 428d6ef7..ce71bde0 100644
--- a/logic/OneSixUpdate.cpp
+++ b/logic/OneSixUpdate.cpp
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+#include "MultiMC.h"
#include "OneSixUpdate.h"
#include <QtNetwork>
@@ -72,7 +72,9 @@ void OneSixUpdate::versionFileStart()
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
urlstr += targetVersion->descriptor + "/" + targetVersion->descriptor + ".json";
- specificVersionDownloadJob.reset(new DownloadJob(QUrl(urlstr)));
+ auto job = new DownloadJob("Version index");
+ job->add(QUrl(urlstr));
+ specificVersionDownloadJob.reset(job);
connect(specificVersionDownloadJob.data(), SIGNAL(succeeded()), SLOT(versionFileFinished()));
connect(specificVersionDownloadJob.data(), SIGNAL(failed()), SLOT(versionFileFailed()));
connect(specificVersionDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64)));
@@ -92,7 +94,7 @@ void OneSixUpdate::versionFileFinished()
// FIXME: detect errors here, download to a temp file, swap
QFile vfile1 (version1);
vfile1.open(QIODevice::Truncate | QIODevice::WriteOnly );
- vfile1.write(DlJob->m_data);
+ vfile1.write(DlJob.dynamicCast<ByteArrayDownload>()->m_data);
vfile1.close();
}
@@ -134,16 +136,22 @@ void OneSixUpdate::jarlibStart()
QString targetstr ("versions/");
targetstr += version->id + "/" + version->id + ".jar";
- jarlibDownloadJob.reset(new DownloadJob(QUrl(urlstr), targetstr));
+ auto job = new DownloadJob("Libraries for instance " + inst->name());
+ job->add(QUrl(urlstr), targetstr);
+ jarlibDownloadJob.reset(job);
auto libs = version->getActiveNativeLibs();
libs.append(version->getActiveNormalLibs());
+ auto metacache = MMC->metacache();
for(auto lib: libs)
{
QString download_path = lib->downloadPath();
- QString storage_path = "libraries/" + lib->storagePath();
- jarlibDownloadJob->add(download_path, storage_path);
+ auto entry = metacache->resolveEntry("libraries", lib->storagePath());
+ if(entry->stale)
+ {
+ jarlibDownloadJob->add(download_path, entry);
+ }
}
connect(jarlibDownloadJob.data(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
connect(jarlibDownloadJob.data(), SIGNAL(failed()), SLOT(jarlibFailed()));