Merge lp:~mandel/ubuntu-download-manager/continue-after-chechsum-error into lp:ubuntu-download-manager

Proposed by Manuel de la Peña
Status: Merged
Approved by: Roberto Alsina
Approved revision: 126
Merged at revision: 128
Proposed branch: lp:~mandel/ubuntu-download-manager/continue-after-chechsum-error
Merge into: lp:ubuntu-download-manager
Diff against target: 75 lines (+13/-9)
2 files modified
libubuntudownloadmanager/single_download.cpp (+5/-6)
ubuntu-download-manager-tests/test_download.cpp (+8/-3)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/continue-after-chechsum-error
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
PS Jenkins bot continuous-integration Approve
Diego Sarmentero (community) Approve
Review via email: mp+186488@code.launchpad.net

Commit message

Ensure that when there is a hash error the state change is emitted and is the correct download state.

Description of the change

Ensure that when there is a hash error the state change is emitted and is the correct download state.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
125. By Manuel de la Peña

Increase debuging.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
126. By Manuel de la Peña

Import QSslError

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libubuntudownloadmanager/single_download.cpp'
--- libubuntudownloadmanager/single_download.cpp 2013-09-18 12:24:49 +0000
+++ libubuntudownloadmanager/single_download.cpp 2013-09-19 15:34:47 +0000
@@ -22,6 +22,7 @@
22#include <QStringList>22#include <QStringList>
23#include <QFile>23#include <QFile>
24#include <QFileInfo>24#include <QFileInfo>
25#include <QSslError>
25#include "./single_download.h"26#include "./single_download.h"
26#include "./network_reply.h"27#include "./network_reply.h"
27#include "./xdg_basedir.h"28#include "./xdg_basedir.h"
@@ -264,8 +265,7 @@
264 QCryptographicHash::hash(data, _algo).toHex());265 QCryptographicHash::hash(data, _algo).toHex());
265 if (fileSig != _hash) {266 if (fileSig != _hash) {
266 qCritical() << "HASH ERROR:" << fileSig << "!=" << _hash;267 qCritical() << "HASH ERROR:" << fileSig << "!=" << _hash;
267 q->setState(Download::FINISH);268 emitError("HASH ERROR");
268 emit q->error("HASH ERROR");
269 return;269 return;
270 }270 }
271 }271 }
@@ -282,8 +282,7 @@
282 if (commandData.count() == 0) {282 if (commandData.count() == 0) {
283 // raise error, command metadata was passed without the commnad283 // raise error, command metadata was passed without the commnad
284 qCritical() << "COMMAND DATA MISSING";284 qCritical() << "COMMAND DATA MISSING";
285 q->setState(Download::FINISH);285 emitError("COMMAND ERROR");
286 emit q->error("COMMAND ERROR");
287 return;286 return;
288 } else {287 } else {
289 // first item of the string list is the commnad288 // first item of the string list is the commnad
@@ -328,9 +327,9 @@
328327
329 void onSslErrors(const QList<QSslError>& errors) {328 void onSslErrors(const QList<QSslError>& errors) {
330 qDebug() << __PRETTY_FUNCTION__ << _url;329 qDebug() << __PRETTY_FUNCTION__ << _url;
330 qDebug() << "Found errors" << errors;
331 Q_UNUSED(errors);331 Q_UNUSED(errors);
332 Q_Q(SingleDownload);332 emitError("SSL ERROR");
333 emit q->error("SSL ERROR");
334 }333 }
335334
336 // slots executed to keep track of the post download process335 // slots executed to keep track of the post download process
337336
=== modified file 'ubuntu-download-manager-tests/test_download.cpp'
--- ubuntu-download-manager-tests/test_download.cpp 2013-09-18 12:39:37 +0000
+++ ubuntu-download-manager-tests/test_download.cpp 2013-09-19 15:34:47 +0000
@@ -896,7 +896,7 @@
896 QSharedPointer<SystemNetworkInfo>(_networkInfo),896 QSharedPointer<SystemNetworkInfo>(_networkInfo),
897 QSharedPointer<RequestFactory>(_reqFactory),897 QSharedPointer<RequestFactory>(_reqFactory),
898 QSharedPointer<ProcessFactory>(_processFactory));898 QSharedPointer<ProcessFactory>(_processFactory));
899 QSignalSpy spy(download , SIGNAL(error(QString)));899 QSignalSpy errorSpy(download , SIGNAL(error(QString)));
900900
901 download->start(); // change state901 download->start(); // change state
902 download->startDownload();902 download->startDownload();
@@ -919,11 +919,16 @@
919 calledMethods = _reqFactory->calledMethods();919 calledMethods = _reqFactory->calledMethods();
920 reply = reinterpret_cast<FakeNetworkReply*>(920 reply = reinterpret_cast<FakeNetworkReply*>(
921 calledMethods[0].params().outParams()[0]);921 calledMethods[0].params().outParams()[0]);
922
923 // create the spy here else we will register other not interesting
924 // signals
925 QSignalSpy stateSpy(download , SIGNAL(stateChanged()));
922 emit reply->finished();926 emit reply->finished();
923927
924 // the has is a random string so we should get an error signal928 // the has is a random string so we should get an error signal
925 QCOMPARE(spy.count(), 1);929 QCOMPARE(errorSpy.count(), 1);
926 QCOMPARE(download->state(), Download::FINISH);930 QCOMPARE(stateSpy.count(), 1);
931 QCOMPARE(download->state(), Download::ERROR);
927932
928 delete download;933 delete download;
929}934}

Subscribers

People subscribed via source and target branches