Merge lp:~mandel/ubuntu-download-manager/allow-empty-hash into lp:ubuntu-download-manager

Proposed by Manuel de la Peña
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 142
Merged at revision: 141
Proposed branch: lp:~mandel/ubuntu-download-manager/allow-empty-hash
Merge into: lp:ubuntu-download-manager
Diff against target: 99 lines (+15/-16)
4 files modified
libubuntudownloadmanager/group_download.cpp (+6/-9)
libubuntudownloadmanager/hash_algorithm.cpp (+1/-1)
ubuntu-download-manager-tests/test_download.cpp (+1/-0)
ubuntu-download-manager-tests/test_group_download.cpp (+7/-6)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/allow-empty-hash
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Alejandro J. Cura (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+188161@code.launchpad.net

Commit message

Allow the hash method to be empty.

Description of the change

Allow the hash method to be empty.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks good.

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

Trust the code in the single download.

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

Fix failing test.

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

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-25 15:11:51 +0000
3+++ libubuntudownloadmanager/group_download.cpp 2013-09-27 21:58:14 +0000
4@@ -71,15 +71,6 @@
5 QVariantMap metadata = q->metadata();
6 QMap<QString, QString> headers = q->headers();
7
8- // check if the algo is correct if not do not even build the
9- // single downloads
10- if (!HashAlgorithm::isValidAlgo(algo)) {
11- q->setIsValid(false);
12- q->setLastError(
13- QString("Invalid hash algorithm: '%1'").arg(algo));
14- return;
15- }
16-
17 // build downloads and add them to the q, it will take care of
18 // starting them etc..
19 foreach(GroupDownloadStruct download, downloads) {
20@@ -108,6 +99,12 @@
21 _downFactory->createDownloadForGroup(q->isConfined(),
22 q->rootPath(), url, downloadMetadata, headers));
23 } else {
24+
25+ if (!HashAlgorithm::isValidAlgo(algo)) {
26+ q->setIsValid(false);
27+ q->setLastError(QString("Invalid hash algorithm: '%1'").arg(algo));
28+ }
29+
30 qDebug() << "Creating SingleDownload with hash.";
31 singleDownload = qobject_cast<SingleDownload*>(
32 _downFactory->createDownloadForGroup(q->isConfined(),
33
34=== modified file 'libubuntudownloadmanager/hash_algorithm.cpp'
35--- libubuntudownloadmanager/hash_algorithm.cpp 2013-09-24 12:08:24 +0000
36+++ libubuntudownloadmanager/hash_algorithm.cpp 2013-09-27 21:58:14 +0000
37@@ -19,7 +19,7 @@
38 #include "./hash_algorithm.h"
39
40 QList<QString> HashAlgorithm::algoList = QList<QString>() << "md5" << "sha1"
41- << "sha224" << "sha256" << "sha384" << "sha512";
42+ << "sha224" << "sha256" << "sha384" << "sha512" << "";
43
44 QCryptographicHash::Algorithm
45 HashAlgorithm::getHashAlgo(const QString& algorithm) {
46
47=== modified file 'ubuntu-download-manager-tests/test_download.cpp'
48--- ubuntu-download-manager-tests/test_download.cpp 2013-09-25 09:12:06 +0000
49+++ ubuntu-download-manager-tests/test_download.cpp 2013-09-27 21:58:14 +0000
50@@ -1773,6 +1773,7 @@
51 QTest::newRow("sha256") << "sha256";
52 QTest::newRow("sha384") << "sha384";
53 QTest::newRow("sha512") << "sha512";
54+ QTest::newRow("Empty string") << "";
55 }
56
57 void
58
59=== modified file 'ubuntu-download-manager-tests/test_group_download.cpp'
60--- ubuntu-download-manager-tests/test_group_download.cpp 2013-09-25 09:12:06 +0000
61+++ ubuntu-download-manager-tests/test_group_download.cpp 2013-09-27 21:58:14 +0000
62@@ -807,11 +807,11 @@
63 TestGroupDownload::testInvalidHashAlgorithm() {
64 QList<GroupDownloadStruct> downloadsStruct;
65 downloadsStruct.append(GroupDownloadStruct("http://one.ubuntu.com",
66- "local_file", ""));
67+ "local_file", "asasas"));
68 downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com",
69- "other_local_file", ""));
70+ "other_local_file", "sasas"));
71 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
72- "other_reddit_local_file", ""));
73+ "other_reddit_local_file", "sasaas"));
74
75 GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
76 downloadsStruct, "wrong", _isGSMDownloadAllowed, _metadata, _headers,
77@@ -832,6 +832,7 @@
78 QTest::newRow("sha256") << "sha256";
79 QTest::newRow("sha384") << "sha384";
80 QTest::newRow("sha512") << "sha512";
81+ QTest::newRow("Empty string") << "";
82 }
83
84 void
85@@ -839,11 +840,11 @@
86 QFETCH(QString, algo);
87 QList<GroupDownloadStruct> downloadsStruct;
88 downloadsStruct.append(GroupDownloadStruct("http://one.ubuntu.com",
89- "local_file", ""));
90+ "local_file", "asasas"));
91 downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com",
92- "other_local_file", ""));
93+ "other_local_file", "asasas"));
94 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
95- "other_reddit_local_file", ""));
96+ "other_reddit_local_file", "sasa"));
97
98 GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
99 downloadsStruct, algo, _isGSMDownloadAllowed, _metadata, _headers,

Subscribers

People subscribed via source and target branches