summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base/zipinstaller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/base/zipinstaller.cpp')
-rw-r--r--rbutil/rbutilqt/base/zipinstaller.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/rbutil/rbutilqt/base/zipinstaller.cpp b/rbutil/rbutilqt/base/zipinstaller.cpp
index b2c8e09178..caf1b52945 100644
--- a/rbutil/rbutilqt/base/zipinstaller.cpp
+++ b/rbutil/rbutilqt/base/zipinstaller.cpp
@@ -22,11 +22,10 @@
22#include "ziputil.h" 22#include "ziputil.h"
23#include "Logger.h" 23#include "Logger.h"
24 24
25ZipInstaller::ZipInstaller(QObject* parent): QObject(parent) 25ZipInstaller::ZipInstaller(QObject* parent) :
26 QObject(parent),
27 m_unzip(true), m_usecache(false), m_getter(0)
26{ 28{
27 m_unzip = true;
28 m_usecache = false;
29 m_getter = 0;
30} 29}
31 30
32 31
@@ -34,11 +33,11 @@ void ZipInstaller::install()
34{ 33{
35 LOG_INFO() << "initializing installation"; 34 LOG_INFO() << "initializing installation";
36 35
37 runner = 0; 36 m_runner = 0;
38 connect(this, SIGNAL(cont()), this, SLOT(installContinue())); 37 connect(this, SIGNAL(cont()), this, SLOT(installContinue()));
39 m_url = m_urllist.at(runner); 38 m_url = m_urllist.at(m_runner);
40 m_logsection = m_loglist.at(runner); 39 m_logsection = m_loglist.at(m_runner);
41 m_logver = m_verlist.at(runner); 40 m_logver = m_verlist.at(m_runner);
42 installStart(); 41 installStart();
43} 42}
44 43
@@ -54,13 +53,13 @@ void ZipInstaller::installContinue()
54{ 53{
55 LOG_INFO() << "continuing installation"; 54 LOG_INFO() << "continuing installation";
56 55
57 runner++; // this gets called when a install finished, so increase first. 56 m_runner++; // this gets called when a install finished, so increase first.
58 LOG_INFO() << "runner done:" << runner << "/" << m_urllist.size(); 57 LOG_INFO() << "runner done:" << m_runner << "/" << m_urllist.size();
59 if(runner < m_urllist.size()) { 58 if(m_runner < m_urllist.size()) {
60 emit logItem(tr("done."), LOGOK); 59 emit logItem(tr("done."), LOGOK);
61 m_url = m_urllist.at(runner); 60 m_url = m_urllist.at(m_runner);
62 m_logsection = m_loglist.at(runner); 61 m_logsection = m_loglist.at(m_runner);
63 if(runner < m_verlist.size()) m_logver = m_verlist.at(runner); 62 if(m_runner < m_verlist.size()) m_logver = m_verlist.at(m_runner);
64 else m_logver = ""; 63 else m_logver = "";
65 installStart(); 64 installStart();
66 } 65 }
@@ -69,7 +68,6 @@ void ZipInstaller::installContinue()
69 emit done(false); 68 emit done(false);
70 return; 69 return;
71 } 70 }
72
73} 71}
74 72
75 73
@@ -158,18 +156,22 @@ void ZipInstaller::downloadDone(bool error)
158 zip.close(); 156 zip.close();
159 } 157 }
160 else { 158 else {
159 if (m_target.isEmpty())
160 m_target = QUrl(m_url).fileName();
161 QString destfile = m_mountpoint + "/" + m_target;
161 // only copy the downloaded file to the output location / name 162 // only copy the downloaded file to the output location / name
162 emit logItem(tr("Installing file."), LOGINFO); 163 emit logItem(tr("Installing file."), LOGINFO);
163 LOG_INFO() << "saving downloaded file (no extraction)"; 164 LOG_INFO() << "saving downloaded file (no extraction) to" << destfile;
164 165
165 m_downloadFile->open(); // copy fails if file is not opened (filename issue?) 166 m_downloadFile->open(); // copy fails if file is not opened (filename issue?)
166 // make sure the required path is existing 167 // make sure the required path is existing
167 QString path = QFileInfo(m_mountpoint + m_target).absolutePath(); 168 QString path = QFileInfo(destfile).absolutePath();
168 QDir p; 169 QDir p;
169 p.mkpath(path); 170 p.mkpath(path);
170 // QFile::copy() doesn't overwrite files, so remove old one first 171 // QFile::copy() doesn't overwrite files, so remove old one first
171 QFile(m_mountpoint + m_target).remove(); 172 // TODO: compare old and new file and fail if those are different.
172 if(!m_downloadFile->copy(m_mountpoint + m_target)) { 173 QFile(destfile).remove();
174 if(!m_downloadFile->copy(destfile)) {
173 emit logItem(tr("Installing file failed."), LOGERROR); 175 emit logItem(tr("Installing file failed."), LOGERROR);
174 emit done(true); 176 emit done(true);
175 return; 177 return;