ZipInstaller: rename some member variables to be in line with the rest.

Also change the double inclusion protection to match the filename.

Change-Id: I5bb64afdb62c87057867f9f9d683f0df239d2efc
This commit is contained in:
Dominik Riebeling 2013-03-09 19:37:40 +01:00
parent e50066718c
commit af58d04e35
2 changed files with 24 additions and 26 deletions

View File

@ -25,7 +25,7 @@ ZipInstaller::ZipInstaller(QObject* parent): QObject(parent)
{
m_unzip = true;
m_usecache = false;
getter = 0;
m_getter = 0;
}
@ -83,23 +83,23 @@ void ZipInstaller::installStart()
// make sure to get a fresh one on each run.
// making this a parent of the temporary file ensures the file gets deleted
// after the class object gets destroyed.
downloadFile = new QTemporaryFile(this);
downloadFile->open();
m_file = downloadFile->fileName();
downloadFile->close();
m_downloadFile = new QTemporaryFile(this);
m_downloadFile->open();
m_file = m_downloadFile->fileName();
m_downloadFile->close();
// get the real file.
if(getter != 0) getter->deleteLater();
getter = new HttpGet(this);
if(m_getter != 0) m_getter->deleteLater();
m_getter = new HttpGet(this);
if(m_usecache) {
getter->setCache(true);
m_getter->setCache(true);
}
getter->setFile(downloadFile);
m_getter->setFile(m_downloadFile);
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
connect(getter, SIGNAL(dataReadProgress(int, int)), this, SIGNAL(logProgress(int, int)));
connect(this, SIGNAL(internalAborted()), getter, SLOT(abort()));
connect(m_getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
connect(m_getter, SIGNAL(dataReadProgress(int, int)), this, SIGNAL(logProgress(int, int)));
connect(this, SIGNAL(internalAborted()), m_getter, SLOT(abort()));
getter->getFile(QUrl(m_url));
m_getter->getFile(QUrl(m_url));
}
@ -110,16 +110,16 @@ void ZipInstaller::downloadDone(bool error)
// update progress bar
emit logProgress(1, 1);
if(getter->httpResponse() != 200 && !getter->isCached()) {
if(m_getter->httpResponse() != 200 && !m_getter->isCached()) {
emit logItem(tr("Download error: received HTTP error %1.")
.arg(getter->httpResponse()),LOGERROR);
.arg(m_getter->httpResponse()),LOGERROR);
emit done(true);
return;
}
if(getter->isCached())
if(m_getter->isCached())
emit logItem(tr("Cached file used."), LOGINFO);
if(error) {
emit logItem(tr("Download error: %1").arg(getter->errorString()), LOGERROR);
emit logItem(tr("Download error: %1").arg(m_getter->errorString()), LOGERROR);
emit done(true);
return;
}
@ -161,14 +161,14 @@ void ZipInstaller::downloadDone(bool error)
emit logItem(tr("Installing file."), LOGINFO);
qDebug() << "[ZipInstall] saving downloaded file (no extraction)";
downloadFile->open(); // copy fails if file is not opened (filename issue?)
m_downloadFile->open(); // copy fails if file is not opened (filename issue?)
// make sure the required path is existing
QString path = QFileInfo(m_mountpoint + m_target).absolutePath();
QDir p;
p.mkpath(path);
// QFile::copy() doesn't overwrite files, so remove old one first
QFile(m_mountpoint + m_target).remove();
if(!downloadFile->copy(m_mountpoint + m_target)) {
if(!m_downloadFile->copy(m_mountpoint + m_target)) {
emit logItem(tr("Installing file failed."), LOGERROR);
emit done(true);
return;
@ -179,7 +179,7 @@ void ZipInstaller::downloadDone(bool error)
}
if(m_logver.isEmpty()) {
// if no version info is set use the timestamp of the server file.
m_logver = getter->timestamp().toString(Qt::ISODate);
m_logver = m_getter->timestamp().toString(Qt::ISODate);
}
emit logItem(tr("Creating installation log"),LOGINFO);

View File

@ -19,10 +19,8 @@
****************************************************************************/
#ifndef INSTALLZIP_H
#define INSTALLZIP_H
#ifndef ZIPINSTALLER_H
#define ZIPINSTALLER_H
#include <QtCore>
@ -75,8 +73,8 @@ private:
QDir m_cache;
bool m_usecache;
HttpGet *getter;
QTemporaryFile *downloadFile;
HttpGet *m_getter;
QTemporaryFile *m_downloadFile;
};