Merge lp:~mandel/ubuntu-system-settings/download-checksum into lp:ubuntu-system-settings/rtm-14.09

Proposed by Manuel de la Peña
Status: Rejected
Rejected by: Sebastien Bacher
Proposed branch: lp:~mandel/ubuntu-system-settings/download-checksum
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 234 lines (+29/-34)
6 files modified
plugins/system-update/PageComponent.qml (+11/-28)
plugins/system-update/download_tracker.cpp (+5/-5)
plugins/system-update/download_tracker.h (+5/-1)
plugins/system-update/network/network.cpp (+2/-0)
plugins/system-update/update.cpp (+1/-0)
plugins/system-update/update.h (+5/-0)
To merge this branch: bzr merge lp:~mandel/ubuntu-system-settings/download-checksum
Reviewer Review Type Date Requested Status
Ken VanDine Disapprove
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+249214@code.launchpad.net

Commit message

Add checksum support for the click downloads.

Description of the change

Backport the checksum support for the download manager that is present in trunk.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

I have proposed a branch for the backport already, can you look at https://code.launchpad.net/~ken-vandine/ubuntu-system-settings/rtm-check-hash/+merge/247489

I've been holding off trying to land that until we get the error case fixed, any progress on that?

review: Disapprove

Unmerged revisions

989. By Manuel de la Peña

Backport the checksum support that was added in vivid.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/system-update/PageComponent.qml'
2--- plugins/system-update/PageComponent.qml 2015-01-30 18:36:21 +0000
3+++ plugins/system-update/PageComponent.qml 2015-02-10 16:30:49 +0000
4@@ -47,6 +47,11 @@
5 property var notificationAction;
6 property string errorDialogText: ""
7
8+ onUpdatesAvailableChanged: {
9+ if (updatesAvailable < 1 && root.state != "SEARCHING")
10+ root.state = "NOUPDATES";
11+ }
12+
13 QDBusActionGroup {
14 id: indicatorPower
15 busType: 1
16@@ -508,11 +513,11 @@
17 fontSize: "small"
18 text: {
19 if (!labelUpdateStatus.visible)
20- return convert_bytes_to_size(modelData.binaryFilesize);
21+ return Utilities.formatSize(modelData.binaryFilesize);
22
23 return i18n.tr("%1 of %2").arg(
24- convert_bytes_to_size(modelData.binaryFilesize * (progress.value * 0.01))).arg(
25- convert_bytes_to_size(modelData.binaryFilesize)
26+ Utilities.formatSize(modelData.binaryFilesize * (progress.value * 0.01))).arg(
27+ Utilities.formatSize(modelData.binaryFilesize)
28 );
29 }
30 }
31@@ -538,6 +543,7 @@
32 packageName: modelData.packageName
33 clickToken: modelData.clickToken
34 download: modelData.downloadUrl
35+ downloadSha512: modelData.downloadSha512
36
37 onFinished: {
38 progress.visible = false;
39@@ -613,12 +619,12 @@
40 elide: Text.ElideRight
41 fontSize: "small"
42 }
43-
44+
45 Label {
46 id: labelSize
47 objectName: "labelSize"
48 anchors.right: parent.right
49- text: convert_bytes_to_size(modelData.binaryFilesize)
50+ text: Utilities.formatSize(modelData.binaryFilesize)
51 fontSize: "small"
52 visible: !labelUpdateStatus.visible && !installing && !installed
53 }
54@@ -746,27 +752,4 @@
55 onClicked: pageStack.push(Qt.resolvedUrl("Configuration.qml"))
56 }
57 }
58-
59- function convert_bytes_to_size(bytes) {
60- var SIZE_IN_GIB = 1024.0 * 1024.0 * 1024.0;
61- var SIZE_IN_MIB = 1024.0 * 1024.0;
62- var SIZE_IN_KIB = 1024.0;
63-
64- var result = "";
65- var size = 0;
66- if (bytes < SIZE_IN_KIB) {
67- result = bytes + i18n.tr(" bytes");
68- } else if (bytes < SIZE_IN_MIB) {
69- size = (bytes / SIZE_IN_KIB).toFixed(1);
70- result = size + i18n.tr(" KiB");
71- } else if (bytes < SIZE_IN_GIB) {
72- size = (bytes / SIZE_IN_MIB).toFixed(1);
73- result = size + i18n.tr(" MiB");
74- } else {
75- size = (bytes / SIZE_IN_GIB).toFixed(1);
76- result = size + i18n.tr(" GiB");
77- }
78-
79- return result;
80- }
81 }
82
83=== modified file 'plugins/system-update/download_tracker.cpp'
84--- plugins/system-update/download_tracker.cpp 2015-01-15 11:08:33 +0000
85+++ plugins/system-update/download_tracker.cpp 2015-02-10 16:30:49 +0000
86@@ -1,5 +1,5 @@
87 /*
88- * Copyright (C) 2014 - Canonical Ltd.
89+ * Copyright (C) 2014-2015 - Canonical Ltd.
90 *
91 * This program is free software: you can redistribute it and/or modify it
92 * under the terms of the GNU Lesser General Public License, as
93@@ -18,19 +18,19 @@
94 * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>
95 */
96
97-#include <QDebug>
98-#include <QProcessEnvironment>
99-
100 #include <ubuntu/download_manager/download_struct.h>
101 #include <ubuntu/download_manager/error.h>
102+#include <QProcessEnvironment>
103
104 #include "download_tracker.h"
105 #include "network/network.h"
106
107+
108 namespace {
109 const QString DOWNLOAD_COMMAND = "post-download-command";
110 const QString APP_ID = "app_id";
111 const QString PKCON_COMMAND = "pkcon";
112+ const QString DOWNLOAD_MANAGER_SHA512 = "sha512";
113 }
114
115 namespace UpdatePlugin {
116@@ -88,7 +88,7 @@
117 vmap[APP_ID] = m_packageName;
118 StringMap map;
119 map[X_CLICK_TOKEN] = m_clickToken;
120- DownloadStruct dstruct = DownloadStruct(m_downloadUrl, vmap, map);
121+ DownloadStruct dstruct(m_downloadUrl, m_download_sha512, DOWNLOAD_MANAGER_SHA512, vmap, map);
122 m_manager->createDownload(dstruct);
123 }
124 }
125
126=== modified file 'plugins/system-update/download_tracker.h'
127--- plugins/system-update/download_tracker.h 2015-01-14 11:23:42 +0000
128+++ plugins/system-update/download_tracker.h 2015-02-10 16:30:49 +0000
129@@ -42,6 +42,7 @@
130 Q_PROPERTY(QString clickToken READ clickToken WRITE setClickToken)
131 Q_PROPERTY(QString download READ download WRITE setDownload)
132 Q_PROPERTY(QString packageName READ packageName WRITE setPackageName)
133+ Q_PROPERTY(QString downloadSha512 READ downloadSha512 WRITE setDownloadSha512)
134 Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
135
136 public:
137@@ -54,10 +55,12 @@
138 QString download() { return m_downloadUrl; }
139 QString clickToken() { return m_clickToken; }
140 QString packageName() { return m_packageName; }
141+ QString downloadSha512() { return m_download_sha512; }
142+ int progress() { return m_progress; }
143 void setDownload(const QString& url);
144 void setClickToken(const QString& token);
145 void setPackageName(const QString& package);
146- int progress() { return m_progress; }
147+ void setDownloadSha512(const QString &sha512) { m_download_sha512 = sha512; }
148
149 public Q_SLOTS:
150 void bindDownload(Download* download);
151@@ -84,6 +87,7 @@
152 Download* m_download = nullptr;
153 Manager* m_manager = nullptr;
154 int m_progress = 0;
155+ QString m_download_sha512 = QString::null;
156
157 void startService();
158 QString getPkconCommand();
159
160=== modified file 'plugins/system-update/network/network.cpp'
161--- plugins/system-update/network/network.cpp 2014-09-18 13:50:15 +0000
162+++ plugins/system-update/network/network.cpp 2015-02-10 16:30:49 +0000
163@@ -107,6 +107,7 @@
164 QString version = object.value("version").toString();
165 QString icon_url = object.value("icon_url").toString();
166 QString url = object.value("download_url").toString();
167+ QString download_sha512 = object.value("download_sha512").toString();
168 int size = object.value("binary_filesize").toVariant().toInt();
169 if (m_apps.contains(name)) {
170 m_apps[name]->setRemoteVersion(version);
171@@ -114,6 +115,7 @@
172 m_apps[name]->setIconUrl(icon_url);
173 m_apps[name]->setDownloadUrl(url);
174 m_apps[name]->setBinaryFilesize(size);
175+ m_apps[name]->setDownloadSha512(download_sha512);
176 updates = true;
177 }
178 }
179
180=== modified file 'plugins/system-update/update.cpp'
181--- plugins/system-update/update.cpp 2015-01-14 11:23:42 +0000
182+++ plugins/system-update/update.cpp 2015-02-10 16:30:49 +0000
183@@ -32,6 +32,7 @@
184 QObject(parent),
185 m_binary_filesize(0),
186 m_click_url(""),
187+ m_clickToken(""),
188 m_downloadUrl(""),
189 m_download_progress(0),
190 m_error(""),
191
192=== modified file 'plugins/system-update/update.h'
193--- plugins/system-update/update.h 2014-09-12 19:12:36 +0000
194+++ plugins/system-update/update.h 2015-02-10 16:30:49 +0000
195@@ -57,6 +57,7 @@
196 NOTIFY downloadProgressChanged)
197 Q_PROPERTY(QString downloadUrl READ downloadUrl NOTIFY downloadUrlChanged)
198 Q_PROPERTY(QString clickToken READ clickToken NOTIFY clickTokenChanged)
199+ Q_PROPERTY(QString downloadSha512 READ downloadSha512 NOTIFY downloadSha512Changed)
200
201 Q_SIGNALS:
202 void systemUpdateChanged();
203@@ -75,6 +76,7 @@
204 void downloadUrlChanged();
205 void clickTokenChanged();
206 void packageNameChanged();
207+ void downloadSha512Changed();
208
209 public:
210 explicit Update(QObject *parent = 0);
211@@ -97,6 +99,7 @@
212 const QString& getClickUrl() const { return m_click_url; }
213 QString downloadUrl() { return m_downloadUrl; }
214 QString clickToken() { return m_clickToken; }
215+ QString downloadSha512() { return m_download_sha512; }
216
217 void setSystemUpdate(bool isSystem);
218 void initializeApplication(QString packagename, QString title,
219@@ -115,6 +118,7 @@
220 void setClickUrl(const QString &url) { m_click_url = url; }
221 void setDownloadUrl(const QString &url);
222 void setClickToken(const QString &token) { m_clickToken = token; Q_EMIT clickTokenChanged(); }
223+ void setDownloadSha512(const QString &sha512) { m_download_sha512 = sha512; Q_EMIT downloadSha512Changed(); }
224
225 private:
226 int m_binary_filesize;
227@@ -134,6 +138,7 @@
228 bool m_update;
229 bool m_update_ready;
230 bool m_update_state;
231+ QString m_download_sha512;
232
233 bool getIgnoreUpdates();
234 };

Subscribers

People subscribed via source and target branches