Fixed #4537 by add file error checking

This commit is contained in:
XinyuHou 2015-04-20 16:16:53 +01:00
parent cf6a6bcd48
commit 5e2b8a5048
2 changed files with 13 additions and 6 deletions

View File

@ -94,7 +94,10 @@ bool PluginManager::exist(QString name)
void PluginManager::downloadPlugins()
{
if (m_DataDownloader.isFinished()) {
savePlugin();
if (!savePlugin()) {
return;
}
if (m_DownloadIndex != m_PluginList.size() - 1) {
emit downloadNext();
}
@ -173,7 +176,7 @@ void PluginManager::generateCertificate()
downloadOpenSslSetup();
}
void PluginManager::savePlugin()
bool PluginManager::savePlugin()
{
// create the path if not exist
QDir dir(m_PluginDir);
@ -189,15 +192,19 @@ void PluginManager::savePlugin()
QFile file(filename);
if (!file.open(QIODevice::WriteOnly)) {
emit error(
tr("Failed to download '%1' plugin to: %2")
tr("Failed to download plugin '%1' to: %2 \n %3")
.arg(m_PluginList.at(m_DownloadIndex))
.arg(m_PluginDir));
.arg(m_PluginDir)
.arg(file.errorString()));
return;
file.close();
return false;
}
file.write(m_DataDownloader.data());
file.close();
return true;
}
QString PluginManager::getPluginUrl(const QString& pluginName)

View File

@ -44,7 +44,7 @@ public slots:
void doGenerateCertificate();
private:
void savePlugin();
bool savePlugin();
QString getPluginUrl(const QString& pluginName);
QString getOpenSslSetupUrl();
bool checkOpenSslBinary();