Merge lp:~stolowski/unity-lens-files/hidden-files-6.0 into lp:unity-lens-files/6.0

Proposed by Paweł Stołowski on 2012-11-08
Status: Merged
Approved by: Michal Hruby on 2012-11-08
Approved revision: 241
Merged at revision: 241
Proposed branch: lp:~stolowski/unity-lens-files/hidden-files-6.0
Merge into: lp:unity-lens-files/6.0
Diff against target: 238 lines (+44/-26)
2 files modified
src/daemon.vala (+30/-26)
tests/manual/misc.txt (+14/-0)
To merge this branch: bzr merge lp:~stolowski/unity-lens-files/hidden-files-6.0
Reviewer Review Type Date Requested Status
Michal Hruby (community) 2012-11-08 Approve on 2012-11-08
Review via email: mp+133465@code.launchpad.net

Commit message

Check paths for "/." substring to exclude hidden files. Added manual test.. Fixes: https://bugs.launchpad.net/bugs/878052.
Cherry-picked trunk rev 240..241.

Description of the change

Check paths for "/." substring to exclude hidden files. Added manual test.. Fixes: https://bugs.launchpad.net/bugs/878052.
Cherry-picked trunk rev 240..241.

To post a comment you must log in.
Michal Hruby (mhr3) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon.vala'
2--- src/daemon.vala 2012-09-18 11:39:18 +0000
3+++ src/daemon.vala 2012-11-08 12:03:31 +0000
4@@ -24,9 +24,9 @@
5 using Gee;
6
7 namespace Unity.FilesLens {
8-
9+
10 const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/places/svg/";
11-
12+
13 public class Daemon : GLib.Object
14 {
15 private Zeitgeist.Log log;
16@@ -75,11 +75,11 @@
17 populate_categories ();
18 populate_filters ();
19 lens.add_local_scope (scope);
20-
21+
22 /* Bring up Zeitgeist interfaces */
23 log = new Zeitgeist.Log ();
24 index = new Zeitgeist.Index ();
25-
26+
27 /* Listen for all file:// related events from Zeitgeist */
28 var templates = new PtrArray ();
29 var event = new Zeitgeist.Event ();
30@@ -95,7 +95,7 @@
31
32 bookmarks = new Bookmarks ();
33 urls = new UrlChecker ();
34-
35+
36 devices = new Devices ();
37 devices.changed.connect (() => {
38 /* make sure our results are fresh */
39@@ -204,7 +204,7 @@
40 var cat = new Unity.Category (_("Recent"),
41 new FileIcon (icon_dir.get_child ("group-recent.svg")));
42 categories.append (cat);
43-
44+
45 cat = new Unity.Category (_("Recent Files"),
46 new FileIcon (icon_dir.get_child ("group-recent.svg")));
47 categories.append (cat);
48@@ -234,7 +234,7 @@
49 new Subject.full (uri_prefix,
50 "", "", "", "", "", ""));
51 templates["all"] = event;
52-
53+
54 /* Section.DOCUMENTS */
55 event = new Event.full("", manifestation, "",
56 new Subject.full (uri_prefix,
57@@ -257,7 +257,7 @@
58 new Subject.full (uri_prefix,
59 NFO_IMAGE, "", "", "", "", ""));
60 templates["images"] = event;
61-
62+
63 /* Section.AUDIO */
64 event = new Event.full("", manifestation, "",
65 new Subject.full (uri_prefix,
66@@ -279,7 +279,7 @@
67 NFO_PRESENTATION, "", "", "", "", ""));
68 templates["presentations"] = event;
69
70- /* Section.OTHER
71+ /* Section.OTHER
72 * Note that subject templates are joined with logical AND */
73 event = new Event.full("", manifestation, "");
74 event.add_subject (new Subject.full (uri_prefix,
75@@ -377,7 +377,7 @@
76 private bool is_search_empty (LensSearch search)
77 {
78 if (search.search_string == null) return true;
79-
80+
81 return search.search_string.strip () == "";
82 }
83
84@@ -400,7 +400,7 @@
85
86 return s;
87 }
88-
89+
90 private async void update_global_search_async (LensSearch search,
91 Cancellable cancellable)
92 {
93@@ -423,7 +423,7 @@
94
95 results_model.clear ();
96
97- /* check if the thing typed isn't a url (like facebook.com)
98+ /* check if the thing typed isn't a url (like facebook.com)
99 * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/
100 var url_type = UrlType.UNKNOWN;
101 var checked_url = urls.check_url (search.search_string, out url_type);
102@@ -505,7 +505,7 @@
103 search.search_string, e.message);
104 }
105 }
106-
107+
108 private async void update_search_async (LensSearch search,
109 Cancellable cancellable)
110 {
111@@ -536,13 +536,13 @@
112
113 txn.clear ();
114
115- /* check if the thing typed isn't a url (like facebook.com)
116+ /* check if the thing typed isn't a url (like facebook.com)
117 * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/
118- var url_type = UrlType.UNKNOWN;
119+ var url_type = UrlType.UNKNOWN;
120 var checked_url = urls.check_url (search.search_string, out url_type);
121 if (checked_url != null)
122 {
123- txn.append (checked_url, urls.get_icon_for_type(url_type),
124+ txn.append (checked_url, urls.get_icon_for_type(url_type),
125 Categories.RECENT,
126 "text/html", search.search_string,
127 checked_url, checked_url);
128@@ -625,7 +625,7 @@
129 bookmark_uris);
130
131 GLib.List<Device> matching_devices;
132-
133+
134 if (has_search)
135 matching_devices = devices.search (search.search_string);
136 else
137@@ -709,7 +709,7 @@
138 return;
139 }
140
141- int64[] sizes =
142+ int64[] sizes =
143 {
144 0,
145 1024,
146@@ -934,7 +934,7 @@
147 }
148 } while (info != null);
149 file_iter.close();
150-
151+
152 if (dirs != null)
153 {
154 while (!dirs.is_empty())
155@@ -949,7 +949,7 @@
156 {
157 debug ("Previewing: %s", uri);
158 Unity.GenericPreview preview = null;
159-
160+
161 string real_uri;
162 if (Bookmark.is_bookmark_uri (uri))
163 {
164@@ -1031,7 +1031,7 @@
165 {
166 total_size = finfo.get_size ();
167 preview.add_info (new InfoHint ("size", _("Size"), null, GLib.format_size (total_size)));
168-
169+
170 var open_folder_action = new Unity.PreviewAction ("open-dir", _("Show in Folder"), null);
171 open_folder_action.activated.connect (on_preview_open_folder);
172 preview.add_action (open_folder_action);
173@@ -1085,7 +1085,7 @@
174 free_capacity = file_info.get_attribute_uint64 (GLib.FileAttribute.FILESYSTEM_FREE);
175
176 contents_size = total_capacity - free_capacity;
177-
178+
179 } catch (Error e) {
180 warning ("Failed to query filesystem info: %s", e.message);
181 }
182@@ -1157,9 +1157,9 @@
183 {
184 debug (@"Activating: $uri");
185 try {
186- if (bookmarks.launch_if_bookmark (uri) || devices.launch_if_device (uri))
187+ if (bookmarks.launch_if_bookmark (uri) || devices.launch_if_device (uri))
188 return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH);
189-
190+
191 /* this code ensures that a file manager will be used
192 * * if uri it's a remote location that should be mounted */
193 var url_type = UrlType.UNKNOWN;
194@@ -1234,6 +1234,10 @@
195 if (excluded_uris != null && origin in excluded_uris) continue;
196 if (!(origin in origins) && f.is_native () && f.query_exists ())
197 {
198+ string? path = f.get_path ();
199+ if (path != null && path.contains ("/."))
200+ continue;
201+
202 var display_name = Path.get_basename (f.get_parse_name ());
203 if (display_name.casefold ().has_prefix (folded_search))
204 {
205@@ -1306,7 +1310,8 @@
206 {
207 FileInfo info = file.query_info (check_size ?
208 ATTRS_TYPE_SIZE_HIDDEN : ATTRS_TYPE_HIDDEN, 0, null);
209- if (info.get_is_hidden())
210+ string? path = file.get_path ();
211+ if (path != null && path.contains ("/."))
212 continue;
213 if (check_size &&
214 (info.get_size () < min_size || info.get_size () > max_size))
215@@ -1356,4 +1361,3 @@
216 }
217 }
218 } /* namespace */
219-
220
221=== added file 'tests/manual/misc.txt'
222--- tests/manual/misc.txt 1970-01-01 00:00:00 +0000
223+++ tests/manual/misc.txt 2012-11-08 12:03:31 +0000
224@@ -0,0 +1,14 @@
225+Hidden files / dirs are not displayed
226+-------------------------------------
227+Test that hidden files, hidden folders, or normal files in hidden folders are not displayed in search results.
228+
229+Setup:
230+Create a few combinations of hidden files/folders using nautilus (CTRL+H in nautilus to view hidden files), e.g. ~/.Foo/bar.txt, ~/.foo.txt, ~/.Foo/bar/baz.txt.
231+Update locatedb (e.g. sudo /etc/cron.daily/mlocate).
232+
233+Actions:
234+Type search queries such as "Foo", "bar", "baz" in the dash search query.
235+
236+Expected Result:
237+Verify none of the newly created hidden files are displayed in the Dash home view with empty search.
238+Verify none of the hidden files are displayed after entering a search query.

Subscribers

People subscribed via source and target branches

to all changes: