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
=== modified file 'libubuntudownloadmanager/group_download.cpp'
--- libubuntudownloadmanager/group_download.cpp 2013-09-25 15:11:51 +0000
+++ libubuntudownloadmanager/group_download.cpp 2013-09-27 21:58:14 +0000
@@ -71,15 +71,6 @@
71 QVariantMap metadata = q->metadata();71 QVariantMap metadata = q->metadata();
72 QMap<QString, QString> headers = q->headers();72 QMap<QString, QString> headers = q->headers();
7373
74 // check if the algo is correct if not do not even build the
75 // single downloads
76 if (!HashAlgorithm::isValidAlgo(algo)) {
77 q->setIsValid(false);
78 q->setLastError(
79 QString("Invalid hash algorithm: '%1'").arg(algo));
80 return;
81 }
82
83 // build downloads and add them to the q, it will take care of74 // build downloads and add them to the q, it will take care of
84 // starting them etc..75 // starting them etc..
85 foreach(GroupDownloadStruct download, downloads) {76 foreach(GroupDownloadStruct download, downloads) {
@@ -108,6 +99,12 @@
108 _downFactory->createDownloadForGroup(q->isConfined(),99 _downFactory->createDownloadForGroup(q->isConfined(),
109 q->rootPath(), url, downloadMetadata, headers));100 q->rootPath(), url, downloadMetadata, headers));
110 } else {101 } else {
102
103 if (!HashAlgorithm::isValidAlgo(algo)) {
104 q->setIsValid(false);
105 q->setLastError(QString("Invalid hash algorithm: '%1'").arg(algo));
106 }
107
111 qDebug() << "Creating SingleDownload with hash.";108 qDebug() << "Creating SingleDownload with hash.";
112 singleDownload = qobject_cast<SingleDownload*>(109 singleDownload = qobject_cast<SingleDownload*>(
113 _downFactory->createDownloadForGroup(q->isConfined(),110 _downFactory->createDownloadForGroup(q->isConfined(),
114111
=== modified file 'libubuntudownloadmanager/hash_algorithm.cpp'
--- libubuntudownloadmanager/hash_algorithm.cpp 2013-09-24 12:08:24 +0000
+++ libubuntudownloadmanager/hash_algorithm.cpp 2013-09-27 21:58:14 +0000
@@ -19,7 +19,7 @@
19#include "./hash_algorithm.h"19#include "./hash_algorithm.h"
2020
21QList<QString> HashAlgorithm::algoList = QList<QString>() << "md5" << "sha1"21QList<QString> HashAlgorithm::algoList = QList<QString>() << "md5" << "sha1"
22 << "sha224" << "sha256" << "sha384" << "sha512";22 << "sha224" << "sha256" << "sha384" << "sha512" << "";
2323
24QCryptographicHash::Algorithm24QCryptographicHash::Algorithm
25HashAlgorithm::getHashAlgo(const QString& algorithm) {25HashAlgorithm::getHashAlgo(const QString& algorithm) {
2626
=== modified file 'ubuntu-download-manager-tests/test_download.cpp'
--- ubuntu-download-manager-tests/test_download.cpp 2013-09-25 09:12:06 +0000
+++ ubuntu-download-manager-tests/test_download.cpp 2013-09-27 21:58:14 +0000
@@ -1773,6 +1773,7 @@
1773 QTest::newRow("sha256") << "sha256";1773 QTest::newRow("sha256") << "sha256";
1774 QTest::newRow("sha384") << "sha384";1774 QTest::newRow("sha384") << "sha384";
1775 QTest::newRow("sha512") << "sha512";1775 QTest::newRow("sha512") << "sha512";
1776 QTest::newRow("Empty string") << "";
1776}1777}
17771778
1778void1779void
17791780
=== modified file 'ubuntu-download-manager-tests/test_group_download.cpp'
--- ubuntu-download-manager-tests/test_group_download.cpp 2013-09-25 09:12:06 +0000
+++ ubuntu-download-manager-tests/test_group_download.cpp 2013-09-27 21:58:14 +0000
@@ -807,11 +807,11 @@
807TestGroupDownload::testInvalidHashAlgorithm() {807TestGroupDownload::testInvalidHashAlgorithm() {
808 QList<GroupDownloadStruct> downloadsStruct;808 QList<GroupDownloadStruct> downloadsStruct;
809 downloadsStruct.append(GroupDownloadStruct("http://one.ubuntu.com",809 downloadsStruct.append(GroupDownloadStruct("http://one.ubuntu.com",
810 "local_file", ""));810 "local_file", "asasas"));
811 downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com",811 downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com",
812 "other_local_file", ""));812 "other_local_file", "sasas"));
813 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",813 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
814 "other_reddit_local_file", ""));814 "other_reddit_local_file", "sasaas"));
815815
816 GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,816 GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
817 downloadsStruct, "wrong", _isGSMDownloadAllowed, _metadata, _headers,817 downloadsStruct, "wrong", _isGSMDownloadAllowed, _metadata, _headers,
@@ -832,6 +832,7 @@
832 QTest::newRow("sha256") << "sha256";832 QTest::newRow("sha256") << "sha256";
833 QTest::newRow("sha384") << "sha384";833 QTest::newRow("sha384") << "sha384";
834 QTest::newRow("sha512") << "sha512";834 QTest::newRow("sha512") << "sha512";
835 QTest::newRow("Empty string") << "";
835}836}
836837
837void838void
@@ -839,11 +840,11 @@
839 QFETCH(QString, algo);840 QFETCH(QString, algo);
840 QList<GroupDownloadStruct> downloadsStruct;841 QList<GroupDownloadStruct> downloadsStruct;
841 downloadsStruct.append(GroupDownloadStruct("http://one.ubuntu.com",842 downloadsStruct.append(GroupDownloadStruct("http://one.ubuntu.com",
842 "local_file", ""));843 "local_file", "asasas"));
843 downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com",844 downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com",
844 "other_local_file", ""));845 "other_local_file", "asasas"));
845 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",846 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
846 "other_reddit_local_file", ""));847 "other_reddit_local_file", "sasa"));
847848
848 GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,849 GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
849 downloadsStruct, algo, _isGSMDownloadAllowed, _metadata, _headers,850 downloadsStruct, algo, _isGSMDownloadAllowed, _metadata, _headers,

Subscribers

People subscribed via source and target branches