Merge lp:~ajalkane/ubuntu-filemanager-app/sdcard-less-is-more into lp:ubuntu-filemanager-app

Proposed by Arto Jalkanen
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 375
Merged at revision: 383
Proposed branch: lp:~ajalkane/ubuntu-filemanager-app/sdcard-less-is-more
Merge into: lp:ubuntu-filemanager-app
Diff against target: 156 lines (+41/-50)
4 files modified
src/plugin/placesmodel/placesmodel.cpp (+36/-3)
src/plugin/placesmodel/placesmodel.h (+4/-0)
src/plugin/placesmodel/qmtabparser.cpp (+1/-37)
src/plugin/placesmodel/qmtabparser.h (+0/-10)
To merge this branch: bzr merge lp:~ajalkane/ubuntu-filemanager-app/sdcard-less-is-more
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Carlos Jose Mazieri Approve
Review via email: mp+248444@code.launchpad.net

Commit message

Reduce number of mounts shown in Places bar.

Description of the change

Reduce number of mounts shown in Places bar.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Carla Sella (carla-sella) wrote :

If you look at the video:http://91.189.93.70:8080/job/generic-mediumtests-vivid/964/artifact/filemanager.tests.test_places.PlacesTestCase.test_go_to_root_must_open_the_root_directory.ogv you can see that the folders are missing labels (or name) so the test fails as there is no Object name 'Standard' and properties {'objectName': 'placeDevice'}.

Revision history for this message
Carla Sella (carla-sella) wrote :

The same happens launching the test on my desktop.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Thanks Carla,

I remember seeing this with tests. This hasn't broken anything previously in tests. I don't quite see how this change would suddenly break it, but I will look into it.

Revision history for this message
Carla Sella (carla-sella) wrote :

Arto, I think the problem is in "def patch_home(self):" in file __init__.py line 175 but I do not know how exactly how fixtures works, so I am not sure I can be of much help :(.

Revision history for this message
Carlos Jose Mazieri (carlos-mazieri) wrote :

The code looks OK, later other mounts can be added.

review: Approve
375. By Arto Jalkanen

Trying to fix autopilot test.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/placesmodel/placesmodel.cpp'
2--- src/plugin/placesmodel/placesmodel.cpp 2015-01-03 17:12:34 +0000
3+++ src/plugin/placesmodel/placesmodel.cpp 2015-02-11 19:22:32 +0000
4@@ -28,6 +28,10 @@
5 PlacesModel::PlacesModel(QObject *parent) :
6 QAbstractListModel(parent)
7 {
8+ m_userMountLocation = "/media/" + qgetenv("USER");
9+ // For example /run/user/1000
10+ m_runtimeLocations = QStandardPaths::standardLocations(QStandardPaths::RuntimeLocation);
11+
12 QStringList defaultLocations;
13 // Set the storage location to a path that works well
14 // with app isolation
15@@ -44,6 +48,8 @@
16 defaultLocations.append(locationMusic());
17 defaultLocations.append(locationPictures());
18 defaultLocations.append(locationVideos());
19+ // Add root also
20+ defaultLocations.append("/");
21
22 if (!m_settings->contains("storedLocations")) {
23 m_locations.append(defaultLocations);
24@@ -94,9 +100,7 @@
25
26 foreach (QMtabEntry e, entries) {
27 qDebug() << Q_FUNC_INFO << "Considering" << "fsName:" << e.fsName << "dir:" << e.dir << "type:" << e.type;
28- QFileInfo dir(e.dir);
29- if (dir.isReadable() && dir.isExecutable())
30- {
31+ if (isMtabEntryUserMount(e)) {
32 qDebug() << Q_FUNC_INFO << "Adding as userMount directory dir" << e.dir;
33 userMounts << e.dir;
34 }
35@@ -123,6 +127,35 @@
36 }
37 }
38
39+bool PlacesModel::isMtabEntryUserMount(const QMtabEntry &e) const {
40+ if (e.fsName == "none") {
41+ qDebug() << Q_FUNC_INFO << "Ignoring mounts with filesystem name 'none'";
42+ return false;
43+ }
44+ if (isSubDirectory(m_userMountLocation, e.dir)) {
45+ qDebug() << Q_FUNC_INFO << "Is user mount location";
46+ return true;
47+ }
48+ foreach (const QString &runtimeLocation, m_runtimeLocations) {
49+ if (isSubDirectory(runtimeLocation, e.dir)) {
50+ qDebug() << Q_FUNC_INFO << "Is user mount location";
51+ return true;
52+ }
53+ }
54+
55+ return false;
56+}
57+
58+bool PlacesModel::isSubDirectory(const QString &dir, const QString &path) const {
59+ QFileInfo dirFi = QFileInfo(dir);
60+ QFileInfo pathFi = QFileInfo(path);
61+
62+ QString absDir = dirFi.absolutePath();
63+ QString absPath = pathFi.absolutePath();
64+
65+ return absPath.startsWith(QString(absDir + "/"));
66+}
67+
68 QString PlacesModel::standardLocation(QStandardPaths::StandardLocation location) const
69 {
70 QStringList locations = QStandardPaths::standardLocations(location);
71
72=== modified file 'src/plugin/placesmodel/placesmodel.h'
73--- src/plugin/placesmodel/placesmodel.h 2015-01-03 17:12:34 +0000
74+++ src/plugin/placesmodel/placesmodel.h 2015-02-11 19:22:32 +0000
75@@ -77,6 +77,10 @@
76 void removeItemWithoutStoring(int itemToRemove);
77
78 QMtabParser m_mtabParser;
79+ QStringList m_runtimeLocations;
80+ QString m_userMountLocation;
81+ bool isMtabEntryUserMount(const QMtabEntry &entry) const;
82+ bool isSubDirectory(const QString &dir, const QString &path) const;
83 QString standardLocation(QStandardPaths::StandardLocation location) const;
84 QStringList m_locations;
85 QSettings *m_settings;
86
87=== modified file 'src/plugin/placesmodel/qmtabparser.cpp'
88--- src/plugin/placesmodel/qmtabparser.cpp 2015-01-03 17:18:04 +0000
89+++ src/plugin/placesmodel/qmtabparser.cpp 2015-02-11 19:22:32 +0000
90@@ -64,44 +64,8 @@
91 entry.opts = ent->mnt_opts;
92 entry.freq = ent->mnt_freq;
93 entry.passno = ent->mnt_passno;
94- if (fsHasUserContent(entry)) {
95- entries << entry;
96- }
97+ entries << entry;
98 }
99
100 return entries;
101 }
102-
103-
104-bool QMtabParser::fsHasUserContent(const QMtabEntry &fs)
105-{
106- //check for disk file systems like /dev/sda?
107- bool ret = QFileInfo(fs.fsName).exists();
108- if (!ret)
109- {
110- /*!
111- * \link http://en.wikipedia.org/wiki/List_of_file_systems#Distributed_file_systems
112- */
113- static QStringList netFs = QStringList()
114- << "v9fs"
115- << "afs"
116- << "nfs"
117- << "smb"
118- << "afp"
119- << "dce"
120- << "dfs"
121- << "fal"
122- << "sfs"
123- << "ncp"
124- << "dfs"
125- << "cfs"
126- << "coda"
127- << "MooseFS"
128- << "ssh"
129- << "sftp"
130- << "sshfs"
131- ;
132- ret = netFs.contains(fs.type, Qt::CaseSensitive);
133- }
134- return ret;
135-}
136
137=== modified file 'src/plugin/placesmodel/qmtabparser.h'
138--- src/plugin/placesmodel/qmtabparser.h 2015-01-03 17:18:04 +0000
139+++ src/plugin/placesmodel/qmtabparser.h 2015-02-11 19:22:32 +0000
140@@ -43,16 +43,6 @@
141 QList<QMtabEntry> parseEntries();
142
143 inline const QString& path() { return m_path; }
144-
145-private:
146- /*!
147- * \brief fsHasUserContent() consider Disk and Network file systems as valid
148- * \param fs
149- * \return TRUE if the filesystem is considered as having normal user files, FALSE when it is supposed to be system FS
150- *
151- * \sa \link http://en.wikipedia.org/wiki/List_of_file_systems
152- */
153- bool fsHasUserContent(const struct QMtabEntry& fs);
154 };
155
156 #endif // QMTABPARSER_H

Subscribers

People subscribed via source and target branches