Merge lp:~mikemc/unity-scope-click/add-invalidate-signal into lp:unity-scope-click

Proposed by Mike McCracken
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 139
Merged at revision: 151
Proposed branch: lp:~mikemc/unity-scope-click/add-invalidate-signal
Merge into: lp:unity-scope-click
Prerequisite: lp:~alecu/unity-scope-click/non-click-icons
Diff against target: 58 lines (+21/-4)
2 files modified
scope/click/download-manager.cpp (+16/-2)
scope/tests/test_download_manager.cpp (+5/-2)
To merge this branch: bzr merge lp:~mikemc/unity-scope-click/add-invalidate-signal
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+206813@code.launchpad.net

This proposal supersedes a proposal from 2014-02-14.

Commit message

- Add dbus invalidation signal to post-download command sent to UDM.

Description of the change

- Add dbus invalidation signal to post-download command sent to UDM.

Uses dbus-send to trigger dash invalidation.
Using UDM makes this more robust to preview and scope lifetimes.

To run the (disabled due to ARM Jenkins fun) tests, use
% GTEST_ALSO_RUN_DISABLED_TESTS=1 make test

To test IRL, try this from your scope build dir:
% U1_DEBUG=1 scope/tests/download_manager_tool/download_manager_tool https://public.apps.ubuntu.com/download/com.ubuntu.developer.mzanetti/fahrplan2/com.ubuntu.developer.mzanetti.fahrplan2_2.0.14.1_unknown.click com.ubuntu.developer.mzanetti.fahrplan2 && tail -f ~/.cache/ubuntu-download-manager/UNKNOWN.INFO

If you wait like 10 seconds, you should see a failed installation (assuming you're running on x86). This means that the pkcon part of the command ran as expected.

Q: Error handling: currently I am sending the signal whether or not pkcon succeeds. This is an easy change if that's not the right thing to do.

NOTE:
I haven't been able to test the invalidation command. I need help with this.
Just running the scope with the scope test tool doesn't work, the tool doesn't appear to listen for that signal.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote : Posted in a previous version of this proposal

Looks good, I'd like to see some IRL testing for this.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:139
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~mikemc/unity-scope-click/add-invalidate-signal/+merge/206813/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity-scope-click-ci/311/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-scope-click-trusty-amd64-ci/212
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-scope-click-trusty-armhf-ci/209
        deb: http://jenkins.qa.ubuntu.com/job/unity-scope-click-trusty-armhf-ci/209/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity-scope-click-ci/311/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Rubberstamp on the resubmitted branch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scope/click/download-manager.cpp'
2--- scope/click/download-manager.cpp 2014-02-12 18:01:06 +0000
3+++ scope/click/download-manager.cpp 2014-02-17 21:34:33 +0000
4@@ -32,6 +32,7 @@
5 #include <QDebug>
6 #include <QObject>
7 #include <QString>
8+#include <QStringBuilder>
9 #include <QTimer>
10
11 namespace u1 = UbuntuOne;
12@@ -48,9 +49,22 @@
13
14 static const QString DOWNLOAD_APP_ID_KEY = "app_id";
15 static const QString DOWNLOAD_COMMAND_KEY = "post-download-command";
16+
17+// Pass two commands using sh -c because UDM expects a single
18+// executable.
19+// Use a single string for both commands because the
20+// list is eventually given to QProcess, which adds quotes around each
21+// argument, while -c expects a single quoted string.
22+// Then, use the $0 positional variable in the pkcon command to let us
23+// pass "$file" as a separate list element, which UDM requires for
24+// substitution.
25+static const QString DOWNLOAD_COMMAND = QStringLiteral("pkcon -p install-local $0 && ")
26+ % "dbus-send" % " /com/canonical/unity/scopes" % " com.canonical.unity.scopes.InvalidateResults"
27+ % " string:clickscope";
28 static const QVariant DOWNLOAD_CMDLINE = QVariant(QStringList()
29- << "pkcon" << "-p"
30- << "install-local" << "$file");
31+ << "/bin/sh" << "-c" <<
32+ DOWNLOAD_COMMAND << "$file");
33+
34 static const QString DOWNLOAD_MANAGER_DO_NOT_HASH = "";
35 static const QString DOWNLOAD_MANAGER_IGNORE_HASH_ALGORITHM = "";
36 }
37
38=== modified file 'scope/tests/test_download_manager.cpp'
39--- scope/tests/test_download_manager.cpp 2014-02-12 20:46:36 +0000
40+++ scope/tests/test_download_manager.cpp 2014-02-17 21:34:33 +0000
41@@ -322,13 +322,16 @@
42 ));
43
44
45-MATCHER(DownloadStructIsValid, "Struct is not valid")
46+MATCHER(DownloadStructIsValid, "Download Struct does not match expected")
47 {
48+ auto commandList = arg.getMetadata()["post-download-command"].toStringList();
49 return arg.getUrl() == TEST_URL
50 && arg.getHash() == ""
51 && arg.getAlgorithm() == ""
52 && arg.getMetadata()["app_id"] == QVariant(TEST_APP_ID)
53- && arg.getMetadata()["post-download-command"].toStringList().length() == 4
54+ && commandList[0] == "/bin/sh"
55+ && commandList[1] == "-c"
56+ && commandList[3] == "$files"
57 && arg.getHeaders()["X-Click-Token"] == TEST_CLICK_TOKEN_VALUE;
58 }
59

Subscribers

People subscribed via source and target branches

to all changes: