void ZipInstaller::installStart() { qDebug() << "[ZipInstall] starting installation"; emit logItem(tr("Downloading file %1.%2").arg(QFileInfo(m_url).baseName(), QFileInfo(m_url).completeSuffix()),LOGINFO); // temporary file needs to be opened to get the filename // 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(); // get the real file. getter = new HttpGet(this); if(m_usecache) { getter->setCache(true); } getter->setFile(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())); getter->getFile(QUrl(m_url)); }
void ZipInstaller::abort() { qDebug() << "[ZipInstall] Aborted"; emit internalAborted(); }
void ZipInstaller::downloadDone(bool error) { qDebug() << "[ZipInstall] download done, error:" << error; QStringList zipContents; // needed later // update progress bar emit logProgress(1, 1); if(getter->httpResponse() != 200 && !getter->isCached()) { emit logItem(tr("Download error: received HTTP error %1.") .arg(getter->httpResponse()),LOGERROR); emit done(true); return; } if(getter->isCached()) emit logItem(tr("Cached file used."), LOGINFO); if(error) { emit logItem(tr("Download error: %1").arg(getter->errorString()), LOGERROR); emit done(true); return; } else emit logItem(tr("Download finished."),LOGOK); QCoreApplication::processEvents(); if(m_unzip) { // unzip downloaded file qDebug() << "[ZipInstall] about to unzip " << m_file << "to" << m_mountpoint; emit logItem(tr("Extracting file."), LOGINFO); QCoreApplication::processEvents(); UnZip::ErrorCode ec; RbUnZip uz; connect(&uz, SIGNAL(unzipProgress(int, int)), this, SIGNAL(logProgress(int, int))); connect(this, SIGNAL(internalAborted()), &uz, SLOT(abortUnzip())); ec = uz.openArchive(m_file); if(ec != UnZip::Ok) { emit logItem(tr("Opening archive failed: %1.") .arg(uz.formatError(ec)),LOGERROR); emit logProgress(1, 1); emit done(true); return; } // check for free space. Make sure after installation will still be // some room for operating (also includes calculation mistakes due to // cluster sizes on the player). if(Utils::filesystemFree(m_mountpoint) < (uz.totalSize() + 1000000)) { emit logItem(tr("Not enough disk space! Aborting."), LOGERROR); emit logProgress(1, 1); emit done(true); return; } ec = uz.extractArchive(m_mountpoint); // TODO: better handling of aborted unzip operation. if(ec != UnZip::Ok) { emit logItem(tr("Extracting failed: %1.") .arg(uz.formatError(ec)),LOGERROR); emit logProgress(1, 1); emit done(true); return; } // prepare file list for log zipContents = uz.fileList(); } else {