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
=== modified file 'src/com/ubuntu/content/service/hook.cpp'
--- src/com/ubuntu/content/service/hook.cpp 2014-06-04 16:50:21 +0000
+++ src/com/ubuntu/content/service/hook.cpp 2014-06-26 14:36:31 +0000
@@ -23,6 +23,7 @@
23#include <QDir>23#include <QDir>
24#include <QStandardPaths>24#include <QStandardPaths>
25#include <QTimer>25#include <QTimer>
26#include <QVector>
26#include <com/ubuntu/content/peer.h>27#include <com/ubuntu/content/peer.h>
2728
28#include "debug.h"29#include "debug.h"
@@ -66,13 +67,15 @@
66 * no JSON file installed in this path.67 * no JSON file installed in this path.
67 */68 */
6869
69 QDir contentDir(70 QVector<QDir> contentDirs;
71
72 contentDirs.append(QDir(
70 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)73 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
71 + QString("/")74 + QString("/")
72 + QString("content-hub"));75 + QString("content-hub")));
7376
74 if (not contentDir.exists())77 contentDirs.append(QDir("/usr/share/content-hub/peers/"));
75 return_error();78 contentDirs.append(QDir("/usr/share/local/content-hub/peers/"));
7679
77 QStringList all_peers;80 QStringList all_peers;
78 registry->enumerate_known_peers([&all_peers](const com::ubuntu::content::Peer& peer)81 registry->enumerate_known_peers([&all_peers](const com::ubuntu::content::Peer& peer)
@@ -83,13 +86,36 @@
83 Q_FOREACH(QString p, all_peers)86 Q_FOREACH(QString p, all_peers)
84 {87 {
85 TRACE() << Q_FUNC_INFO << "Looking for" << p;88 TRACE() << Q_FUNC_INFO << "Looking for" << p;
86 QStringList pp = contentDir.entryList(QStringList("*"+ p));89 bool foundPeer = false;
87 if (pp.isEmpty())90 Q_FOREACH(QDir contentDir, contentDirs)
91 {
92 QStringList pp = contentDir.entryList(QStringList("*"+ p));
93 if (!pp.isEmpty()) {
94 foundPeer = true;
95 }
96 }
97 if(!foundPeer) {
88 registry->remove_peer(com::ubuntu::content::Peer{p});98 registry->remove_peer(com::ubuntu::content::Peer{p});
89 }99 }
90100 }
91 Q_FOREACH(QFileInfo f, contentDir.entryInfoList(QDir::Files))101
92 add_peer(f);102 bool peerDirsExist = false;
103
104 Q_FOREACH(QDir contentDir, contentDirs)
105 {
106
107 if (contentDir.exists())
108 {
109 peerDirsExist = true;
110
111 Q_FOREACH(QFileInfo f, contentDir.entryInfoList(QDir::Files))
112 add_peer(f);
113 }
114
115 }
116
117 if(!peerDirsExist)
118 return_error("No peer setting directories exist.");
93119
94 deleteLater();120 deleteLater();
95 QCoreApplication::instance()->quit();121 QCoreApplication::instance()->quit();

Subscribers

People subscribed via source and target branches