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
1=== modified file 'libubuntudownloadmanager/single_download.cpp'
2--- libubuntudownloadmanager/single_download.cpp 2013-09-18 12:24:49 +0000
3+++ libubuntudownloadmanager/single_download.cpp 2013-09-19 15:34:47 +0000
4@@ -22,6 +22,7 @@
5 #include <QStringList>
6 #include <QFile>
7 #include <QFileInfo>
8+#include <QSslError>
9 #include "./single_download.h"
10 #include "./network_reply.h"
11 #include "./xdg_basedir.h"
12@@ -264,8 +265,7 @@
13 QCryptographicHash::hash(data, _algo).toHex());
14 if (fileSig != _hash) {
15 qCritical() << "HASH ERROR:" << fileSig << "!=" << _hash;
16- q->setState(Download::FINISH);
17- emit q->error("HASH ERROR");
18+ emitError("HASH ERROR");
19 return;
20 }
21 }
22@@ -282,8 +282,7 @@
23 if (commandData.count() == 0) {
24 // raise error, command metadata was passed without the commnad
25 qCritical() << "COMMAND DATA MISSING";
26- q->setState(Download::FINISH);
27- emit q->error("COMMAND ERROR");
28+ emitError("COMMAND ERROR");
29 return;
30 } else {
31 // first item of the string list is the commnad
32@@ -328,9 +327,9 @@
33
34 void onSslErrors(const QList<QSslError>& errors) {
35 qDebug() << __PRETTY_FUNCTION__ << _url;
36+ qDebug() << "Found errors" << errors;
37 Q_UNUSED(errors);
38- Q_Q(SingleDownload);
39- emit q->error("SSL ERROR");
40+ emitError("SSL ERROR");
41 }
42
43 // slots executed to keep track of the post download process
44
45=== modified file 'ubuntu-download-manager-tests/test_download.cpp'
46--- ubuntu-download-manager-tests/test_download.cpp 2013-09-18 12:39:37 +0000
47+++ ubuntu-download-manager-tests/test_download.cpp 2013-09-19 15:34:47 +0000
48@@ -896,7 +896,7 @@
49 QSharedPointer<SystemNetworkInfo>(_networkInfo),
50 QSharedPointer<RequestFactory>(_reqFactory),
51 QSharedPointer<ProcessFactory>(_processFactory));
52- QSignalSpy spy(download , SIGNAL(error(QString)));
53+ QSignalSpy errorSpy(download , SIGNAL(error(QString)));
54
55 download->start(); // change state
56 download->startDownload();
57@@ -919,11 +919,16 @@
58 calledMethods = _reqFactory->calledMethods();
59 reply = reinterpret_cast<FakeNetworkReply*>(
60 calledMethods[0].params().outParams()[0]);
61+
62+ // create the spy here else we will register other not interesting
63+ // signals
64+ QSignalSpy stateSpy(download , SIGNAL(stateChanged()));
65 emit reply->finished();
66
67 // the has is a random string so we should get an error signal
68- QCOMPARE(spy.count(), 1);
69- QCOMPARE(download->state(), Download::FINISH);
70+ QCOMPARE(errorSpy.count(), 1);
71+ QCOMPARE(stateSpy.count(), 1);
72+ QCOMPARE(download->state(), Download::ERROR);
73
74 delete download;
75 }

Subscribers

People subscribed via source and target branches