diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-05 17:23:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-06 13:06:50 +0300 |
commit | 05cec243c28f50bd5ee7a167067501f7bd8db3ff (patch) | |
tree | b3b4e97b873ebf5e082ee1092a4c33a1ebdd72b8 /src/gui/windows/updaterwindow.cpp | |
parent | 25bed1bb7f7dbfa3caa0f239c63dbabd3b0bd50d (diff) | |
download | mv-05cec243c28f50bd5ee7a167067501f7bd8db3ff.tar.gz mv-05cec243c28f50bd5ee7a167067501f7bd8db3ff.tar.bz2 mv-05cec243c28f50bd5ee7a167067501f7bd8db3ff.tar.xz mv-05cec243c28f50bd5ee7a167067501f7bd8db3ff.zip |
Validate xml downloads, and if failed, use another mirror.
Diffstat (limited to 'src/gui/windows/updaterwindow.cpp')
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 842176793..dab1a6ebc 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -193,7 +193,8 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, mStoreInMemory(true), mDownloadComplete(true), mUserCancel(false), - mLoadUpdates(applyUpdates) + mLoadUpdates(applyUpdates), + mValidateXml(false) { setWindowName("UpdaterWindow"); setResizable(true); @@ -532,13 +533,16 @@ void UpdaterWindow::download() { mDownload = new Net::Download(this, "http://manaplus.org/update/" + mCurrentFile, - &updateProgress, true, false); + &updateProgress, + true, false, mValidateXml); mDownload->addMirror("http://www.manaplus.org/update/" + mCurrentFile); } else { - mDownload = new Net::Download(this, std::string(mUpdateHost).append( - "/").append(mCurrentFile), &updateProgress, false, false); + mDownload = new Net::Download(this, + std::string(mUpdateHost).append("/").append(mCurrentFile), + &updateProgress, + false, false, mValidateXml); const std::vector<std::string> &mirrors = client->getMirrors(); FOR_EACH (std::vector<std::string>::const_iterator, it, mirrors) @@ -788,6 +792,7 @@ void UpdaterWindow::logic() // Parse current memory buffer as news and dispose of the data loadNews(); + mValidateXml = true; mCurrentFile = xmlUpdateFile; mStoreInMemory = false; mDownloadStatus = UPDATE_LIST; @@ -803,6 +808,7 @@ void UpdaterWindow::logic() mUpdateHost = updateServer2 + mUpdateServerPath; mUpdatesDir.append("/fix"); mCurrentFile = xmlUpdateFile; + mValidateXml = true; mStoreInMemory = false; mDownloadStatus = UPDATE_LIST2; download(); @@ -827,6 +833,7 @@ void UpdaterWindow::logic() // If the resources.xml file fails, // fall back onto a older version mCurrentFile = txtUpdateFile; + mValidateXml = false; mStoreInMemory = false; mDownloadStatus = UPDATE_LIST; download(); @@ -835,6 +842,7 @@ void UpdaterWindow::logic() } else if (mCurrentFile == txtUpdateFile) { + mValidateXml = true; mUpdateFiles = loadTxtFile(std::string(mUpdatesDir).append( "/").append(txtUpdateFile)); } @@ -863,6 +871,7 @@ void UpdaterWindow::logic() std::ifstream temp((std::string(mUpdatesDir).append( "/").append(mCurrentFile)).c_str()); + mValidateXml = false; if (!temp.is_open() || !validateFile(std::string( mUpdatesDir).append("/").append(mCurrentFile), mCurrentChecksum)) @@ -883,6 +892,7 @@ void UpdaterWindow::logic() mCurrentFile = "latest.txt"; mStoreInMemory = true; mDownloadStatus = UPDATE_PATCH; + mValidateXml = false; download(); // download() changes // mDownloadComplete to false } @@ -898,6 +908,7 @@ void UpdaterWindow::logic() } mUpdateIndexOffset = mUpdateIndex; mUpdateIndex = 0; + mValidateXml = true; mStoreInMemory = false; mDownloadStatus = UPDATE_RESOURCES2; download(); @@ -906,6 +917,7 @@ void UpdaterWindow::logic() case UPDATE_RESOURCES2: if (mDownloadComplete) { + mValidateXml = false; if (mUpdateIndex < mTempUpdateFiles.size()) { const UpdateFile thisFile = mTempUpdateFiles[mUpdateIndex]; |