Merge lp:~michael-sheldon/content-hub/debian-peers into lp:content-hub

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 115
Merged at revision: 115
Proposed branch: lp:~michael-sheldon/content-hub/debian-peers
Merge into: lp:content-hub
Diff against target: 75 lines (+37/-11)
1 file modified
src/com/ubuntu/content/service/hook.cpp (+37/-11)
To merge this branch: bzr merge lp:~michael-sheldon/content-hub/debian-peers
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Tiago Salem Herrmann (community) Approve
Review via email: mp+224639@code.launchpad.net

Commit message

Add Debian friendly locations to content-hub-peer-hooks search locations

Description of the change

Adds Debian friendly locations to content-hub-peer-hooks search locations.

To post a comment you must log in.
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

Whats happen if it finds the same app more than once.

IMO the priority should be: (first has more priority)

~/.local/usr/share/content-hub/peers/
/usr/local/share/content-hub/peers/
/usr/share/content-hub/peers/

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Currently the order doesn't make a difference since it ends up being purely additive; so if there's a definition for the same app in multiple locations it ends up with one entry that's a union of all the defined capabilities. That should probably be changed to ignore secondary files (and so also implement the order you suggest).

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

Just tested and it works fine with messaging-app.

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

works, think it's ok as is for now and we can extend it further later

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/com/ubuntu/content/service/hook.cpp'
2--- src/com/ubuntu/content/service/hook.cpp 2014-06-04 16:50:21 +0000
3+++ src/com/ubuntu/content/service/hook.cpp 2014-06-26 14:36:31 +0000
4@@ -23,6 +23,7 @@
5 #include <QDir>
6 #include <QStandardPaths>
7 #include <QTimer>
8+#include <QVector>
9 #include <com/ubuntu/content/peer.h>
10
11 #include "debug.h"
12@@ -66,13 +67,15 @@
13 * no JSON file installed in this path.
14 */
15
16- QDir contentDir(
17+ QVector<QDir> contentDirs;
18+
19+ contentDirs.append(QDir(
20 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
21 + QString("/")
22- + QString("content-hub"));
23-
24- if (not contentDir.exists())
25- return_error();
26+ + QString("content-hub")));
27+
28+ contentDirs.append(QDir("/usr/share/content-hub/peers/"));
29+ contentDirs.append(QDir("/usr/share/local/content-hub/peers/"));
30
31 QStringList all_peers;
32 registry->enumerate_known_peers([&all_peers](const com::ubuntu::content::Peer& peer)
33@@ -83,13 +86,36 @@
34 Q_FOREACH(QString p, all_peers)
35 {
36 TRACE() << Q_FUNC_INFO << "Looking for" << p;
37- QStringList pp = contentDir.entryList(QStringList("*"+ p));
38- if (pp.isEmpty())
39+ bool foundPeer = false;
40+ Q_FOREACH(QDir contentDir, contentDirs)
41+ {
42+ QStringList pp = contentDir.entryList(QStringList("*"+ p));
43+ if (!pp.isEmpty()) {
44+ foundPeer = true;
45+ }
46+ }
47+ if(!foundPeer) {
48 registry->remove_peer(com::ubuntu::content::Peer{p});
49- }
50-
51- Q_FOREACH(QFileInfo f, contentDir.entryInfoList(QDir::Files))
52- add_peer(f);
53+ }
54+ }
55+
56+ bool peerDirsExist = false;
57+
58+ Q_FOREACH(QDir contentDir, contentDirs)
59+ {
60+
61+ if (contentDir.exists())
62+ {
63+ peerDirsExist = true;
64+
65+ Q_FOREACH(QFileInfo f, contentDir.entryInfoList(QDir::Files))
66+ add_peer(f);
67+ }
68+
69+ }
70+
71+ if(!peerDirsExist)
72+ return_error("No peer setting directories exist.");
73
74 deleteLater();
75 QCoreApplication::instance()->quit();

Subscribers

People subscribed via source and target branches