Merge lp:~mandel/ubuntu-download-manager/handle-error-correctly into lp:ubuntu-download-manager

Proposed by Manuel de la Peña
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 121
Merged at revision: 135
Proposed branch: lp:~mandel/ubuntu-download-manager/handle-error-correctly
Merge into: lp:ubuntu-download-manager
Prerequisite: lp:~mandel/ubuntu-download-manager/stoppable
Diff against target: 41 lines (+7/-8)
1 file modified
libubuntudownloadmanager/group_download.cpp (+7/-8)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/handle-error-correctly
Reviewer Review Type Date Requested Status
Barry Warsaw (community) Approve
PS Jenkins bot continuous-integration Approve
Diego Sarmentero (community) Approve
Review via email: mp+187201@code.launchpad.net

Commit message

Ensure that all downloads are canceled and that the files are correctly removed.

Description of the change

Ensure that all downloads are canceled and that the files are correctly removed.

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Barry Warsaw (barry) wrote :

Tested with system-image development branch, and indeed it fixes the problem. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntudownloadmanager/group_download.cpp'
2--- libubuntudownloadmanager/group_download.cpp 2013-09-20 11:28:22 +0000
3+++ libubuntudownloadmanager/group_download.cpp 2013-09-24 10:52:26 +0000
4@@ -111,7 +111,7 @@
5 }
6 }
7
8- void cancelDownload() {
9+ void cancelDownload(bool emitSignal = true) {
10 qDebug() << __PRETTY_FUNCTION__;
11 Q_Q(GroupDownload);
12 foreach(SingleDownload* download, _downloads) {
13@@ -131,7 +131,8 @@
14 _fileManager->remove(path);
15 }
16
17- emit q->canceled(true);
18+ if (emitSignal)
19+ emit q->canceled(true);
20 }
21
22 void pauseDownload() {
23@@ -208,14 +209,12 @@
24 private:
25 // slots to keep track of the downloads
26 void onError(const QString& error) {
27+ qDebug() << __PRETTY_FUNCTION__;
28 Q_Q(GroupDownload);
29 SingleDownload* sender = qobject_cast<SingleDownload*>(q->sender());
30- qDebug() << __PRETTY_FUNCTION__;
31- // we got an error, we remove all the files that have already
32- // been downloaded and emit the error signal
33- foreach(const QString& file, _finishedDownloads) {
34- _fileManager->remove(file);
35- }
36+ // we got an error, cancel all downloads and later remove all the
37+ // files that we managed to download
38+ cancelDownload(false);
39 QString errorMsg = sender->url().toString() + ":" + error;
40 q->emitError(errorMsg);
41 }

Subscribers

People subscribed via source and target branches