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

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 229
Merged at revision: 229
Proposed branch: lp:~stolowski/unity-lens-files/hidden-files-5.0
Merge into: lp:unity-lens-files/5.0
Diff against target: 184 lines (+38/-20)
2 files modified
src/daemon.vala (+24/-20)
tests/manual/misc.txt (+14/-0)
To merge this branch: bzr merge lp:~stolowski/unity-lens-files/hidden-files-5.0
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+133486@code.launchpad.net

Commit message

Check paths for "/." substring to exclude hidden files. Added manual test.
Cherry-picked trunk rev 240..241.

Description of the change

Check paths for "/." substring to exclude hidden files. Added manual test.
Cherry-picked trunk rev 240..241.

To post a comment you must log in.
Revision history for this message
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-04-05 16:11:45 +0000
3+++ src/daemon.vala 2012-11-08 14:18:26 +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@@ -72,11 +72,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@@ -194,7 +194,7 @@
31 var cat = new Unity.Category (_("Recent"),
32 new FileIcon (icon_dir.get_child ("group-recent.svg")));
33 categories.append (cat);
34-
35+
36 cat = new Unity.Category (_("Recent Files"),
37 new FileIcon (icon_dir.get_child ("group-recent.svg")));
38 categories.append (cat);
39@@ -224,7 +224,7 @@
40 new Subject.full (uri_prefix,
41 "", "", "", "", "", ""));
42 templates["all"] = event;
43-
44+
45 /* Section.DOCUMENTS */
46 event = new Event.full("", manifestation, "",
47 new Subject.full (uri_prefix,
48@@ -247,7 +247,7 @@
49 new Subject.full (uri_prefix,
50 NFO_IMAGE, "", "", "", "", ""));
51 templates["images"] = event;
52-
53+
54 /* Section.AUDIO */
55 event = new Event.full("", manifestation, "",
56 new Subject.full (uri_prefix,
57@@ -269,7 +269,7 @@
58 NFO_PRESENTATION, "", "", "", "", ""));
59 templates["presentations"] = event;
60
61- /* Section.OTHER
62+ /* Section.OTHER
63 * Note that subject templates are joined with logical AND */
64 event = new Event.full("", manifestation, "");
65 event.add_subject (new Subject.full (uri_prefix,
66@@ -367,7 +367,7 @@
67 private bool is_search_empty (LensSearch search)
68 {
69 if (search.search_string == null) return true;
70-
71+
72 return search.search_string.strip () == "";
73 }
74
75@@ -390,7 +390,7 @@
76
77 return s;
78 }
79-
80+
81 private async void update_global_search_async (LensSearch search,
82 Cancellable cancellable)
83 {
84@@ -413,7 +413,7 @@
85
86 results_model.clear ();
87
88- /* check if the thing typed isn't a url (like facebook.com)
89+ /* check if the thing typed isn't a url (like facebook.com)
90 * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/
91 var url_type = UrlType.UNKNOWN;
92 var checked_url = urls.check_url (search.search_string, out url_type);
93@@ -483,7 +483,7 @@
94 search.search_string, e.message);
95 }
96 }
97-
98+
99 private async void update_search_async (LensSearch search,
100 Cancellable cancellable)
101 {
102@@ -514,13 +514,13 @@
103
104 txn.clear ();
105
106- /* check if the thing typed isn't a url (like facebook.com)
107+ /* check if the thing typed isn't a url (like facebook.com)
108 * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/
109- var url_type = UrlType.UNKNOWN;
110+ var url_type = UrlType.UNKNOWN;
111 var checked_url = urls.check_url (search.search_string, out url_type);
112 if (checked_url != null)
113 {
114- txn.append (checked_url, urls.get_icon_for_type(url_type),
115+ txn.append (checked_url, urls.get_icon_for_type(url_type),
116 Categories.RECENT,
117 "text/html", search.search_string,
118 checked_url, checked_url);
119@@ -677,7 +677,7 @@
120 return;
121 }
122
123- int64[] sizes =
124+ int64[] sizes =
125 {
126 0,
127 1024,
128@@ -863,9 +863,9 @@
129 {
130 debug (@"Activating: $uri");
131 try {
132- if (bookmarks.launch_if_bookmark (uri))
133+ if (bookmarks.launch_if_bookmark (uri))
134 return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH);
135-
136+
137 /* this code ensures that a file manager will be used
138 * * if uri it's a remote location that should be mounted */
139 var url_type = UrlType.UNKNOWN;
140@@ -940,6 +940,10 @@
141 if (excluded_uris != null && origin in excluded_uris) continue;
142 if (!(origin in origins) && f.is_native () && f.query_exists ())
143 {
144+ string? path = f.get_path ();
145+ if (path != null && path.contains ("/."))
146+ continue;
147+
148 var display_name = Path.get_basename (f.get_parse_name ());
149 if (display_name.casefold ().has_prefix (folded_search))
150 {
151@@ -1012,7 +1016,8 @@
152 {
153 FileInfo info = file.query_info (check_size ?
154 ATTRS_TYPE_SIZE_HIDDEN : ATTRS_TYPE_HIDDEN, 0, null);
155- if (info.get_is_hidden())
156+ string? path = file.get_path ();
157+ if (path != null && path.contains ("/."))
158 continue;
159 if (check_size &&
160 (info.get_size () < min_size || info.get_size () > max_size))
161@@ -1062,4 +1067,3 @@
162 }
163 }
164 } /* namespace */
165-
166
167=== added file 'tests/manual/misc.txt'
168--- tests/manual/misc.txt 1970-01-01 00:00:00 +0000
169+++ tests/manual/misc.txt 2012-11-08 14:18:26 +0000
170@@ -0,0 +1,14 @@
171+Hidden files / dirs are not displayed
172+-------------------------------------
173+Test that hidden files, hidden folders, or normal files in hidden folders are not displayed in search results.
174+
175+Setup:
176+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.
177+Update locatedb (e.g. sudo /etc/cron.daily/mlocate).
178+
179+Actions:
180+Type search queries such as "Foo", "bar", "baz" in the dash search query.
181+
182+Expected Result:
183+Verify none of the newly created hidden files are displayed in the Dash home view with empty search.
184+Verify none of the hidden files are displayed after entering a search query.

Subscribers

People subscribed via source and target branches

to all changes: