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

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 241
Merged at revision: 241
Proposed branch: lp:~stolowski/unity-lens-files/hidden-files
Merge into: lp:unity-lens-files
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
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+132870@code.launchpad.net

Commit message

Check paths for "/." substring to exclude hidden files. Added manual test.

Description of the change

Check paths for "/." substring to exclude hidden files. Added manual test.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Looks good. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/daemon.vala'
--- src/daemon.vala 2012-09-18 11:39:18 +0000
+++ src/daemon.vala 2012-11-05 11:40:31 +0000
@@ -24,9 +24,9 @@
24using Gee;24using Gee;
2525
26namespace Unity.FilesLens {26namespace Unity.FilesLens {
27 27
28 const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/places/svg/";28 const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/places/svg/";
29 29
30 public class Daemon : GLib.Object30 public class Daemon : GLib.Object
31 {31 {
32 private Zeitgeist.Log log;32 private Zeitgeist.Log log;
@@ -75,11 +75,11 @@
75 populate_categories ();75 populate_categories ();
76 populate_filters ();76 populate_filters ();
77 lens.add_local_scope (scope);77 lens.add_local_scope (scope);
78 78
79 /* Bring up Zeitgeist interfaces */79 /* Bring up Zeitgeist interfaces */
80 log = new Zeitgeist.Log ();80 log = new Zeitgeist.Log ();
81 index = new Zeitgeist.Index ();81 index = new Zeitgeist.Index ();
82 82
83 /* Listen for all file:// related events from Zeitgeist */83 /* Listen for all file:// related events from Zeitgeist */
84 var templates = new PtrArray ();84 var templates = new PtrArray ();
85 var event = new Zeitgeist.Event ();85 var event = new Zeitgeist.Event ();
@@ -95,7 +95,7 @@
9595
96 bookmarks = new Bookmarks ();96 bookmarks = new Bookmarks ();
97 urls = new UrlChecker ();97 urls = new UrlChecker ();
98 98
99 devices = new Devices ();99 devices = new Devices ();
100 devices.changed.connect (() => {100 devices.changed.connect (() => {
101 /* make sure our results are fresh */101 /* make sure our results are fresh */
@@ -204,7 +204,7 @@
204 var cat = new Unity.Category (_("Recent"),204 var cat = new Unity.Category (_("Recent"),
205 new FileIcon (icon_dir.get_child ("group-recent.svg")));205 new FileIcon (icon_dir.get_child ("group-recent.svg")));
206 categories.append (cat);206 categories.append (cat);
207 207
208 cat = new Unity.Category (_("Recent Files"),208 cat = new Unity.Category (_("Recent Files"),
209 new FileIcon (icon_dir.get_child ("group-recent.svg")));209 new FileIcon (icon_dir.get_child ("group-recent.svg")));
210 categories.append (cat);210 categories.append (cat);
@@ -234,7 +234,7 @@
234 new Subject.full (uri_prefix,234 new Subject.full (uri_prefix,
235 "", "", "", "", "", ""));235 "", "", "", "", "", ""));
236 templates["all"] = event;236 templates["all"] = event;
237 237
238 /* Section.DOCUMENTS */238 /* Section.DOCUMENTS */
239 event = new Event.full("", manifestation, "",239 event = new Event.full("", manifestation, "",
240 new Subject.full (uri_prefix,240 new Subject.full (uri_prefix,
@@ -257,7 +257,7 @@
257 new Subject.full (uri_prefix,257 new Subject.full (uri_prefix,
258 NFO_IMAGE, "", "", "", "", ""));258 NFO_IMAGE, "", "", "", "", ""));
259 templates["images"] = event;259 templates["images"] = event;
260 260
261 /* Section.AUDIO */261 /* Section.AUDIO */
262 event = new Event.full("", manifestation, "",262 event = new Event.full("", manifestation, "",
263 new Subject.full (uri_prefix,263 new Subject.full (uri_prefix,
@@ -279,7 +279,7 @@
279 NFO_PRESENTATION, "", "", "", "", ""));279 NFO_PRESENTATION, "", "", "", "", ""));
280 templates["presentations"] = event;280 templates["presentations"] = event;
281281
282 /* Section.OTHER 282 /* Section.OTHER
283 * Note that subject templates are joined with logical AND */283 * Note that subject templates are joined with logical AND */
284 event = new Event.full("", manifestation, "");284 event = new Event.full("", manifestation, "");
285 event.add_subject (new Subject.full (uri_prefix,285 event.add_subject (new Subject.full (uri_prefix,
@@ -377,7 +377,7 @@
377 private bool is_search_empty (LensSearch search)377 private bool is_search_empty (LensSearch search)
378 {378 {
379 if (search.search_string == null) return true;379 if (search.search_string == null) return true;
380 380
381 return search.search_string.strip () == "";381 return search.search_string.strip () == "";
382 }382 }
383383
@@ -400,7 +400,7 @@
400400
401 return s;401 return s;
402 }402 }
403 403
404 private async void update_global_search_async (LensSearch search,404 private async void update_global_search_async (LensSearch search,
405 Cancellable cancellable)405 Cancellable cancellable)
406 {406 {
@@ -423,7 +423,7 @@
423423
424 results_model.clear ();424 results_model.clear ();
425425
426 /* check if the thing typed isn't a url (like facebook.com) 426 /* check if the thing typed isn't a url (like facebook.com)
427 * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/427 * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/
428 var url_type = UrlType.UNKNOWN;428 var url_type = UrlType.UNKNOWN;
429 var checked_url = urls.check_url (search.search_string, out url_type);429 var checked_url = urls.check_url (search.search_string, out url_type);
@@ -505,7 +505,7 @@
505 search.search_string, e.message);505 search.search_string, e.message);
506 }506 }
507 }507 }
508 508
509 private async void update_search_async (LensSearch search,509 private async void update_search_async (LensSearch search,
510 Cancellable cancellable)510 Cancellable cancellable)
511 {511 {
@@ -536,13 +536,13 @@
536536
537 txn.clear ();537 txn.clear ();
538538
539 /* check if the thing typed isn't a url (like facebook.com) 539 /* check if the thing typed isn't a url (like facebook.com)
540 * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/540 * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/
541 var url_type = UrlType.UNKNOWN; 541 var url_type = UrlType.UNKNOWN;
542 var checked_url = urls.check_url (search.search_string, out url_type);542 var checked_url = urls.check_url (search.search_string, out url_type);
543 if (checked_url != null)543 if (checked_url != null)
544 {544 {
545 txn.append (checked_url, urls.get_icon_for_type(url_type), 545 txn.append (checked_url, urls.get_icon_for_type(url_type),
546 Categories.RECENT,546 Categories.RECENT,
547 "text/html", search.search_string,547 "text/html", search.search_string,
548 checked_url, checked_url);548 checked_url, checked_url);
@@ -625,7 +625,7 @@
625 bookmark_uris);625 bookmark_uris);
626626
627 GLib.List<Device> matching_devices;627 GLib.List<Device> matching_devices;
628 628
629 if (has_search)629 if (has_search)
630 matching_devices = devices.search (search.search_string);630 matching_devices = devices.search (search.search_string);
631 else631 else
@@ -709,7 +709,7 @@
709 return;709 return;
710 }710 }
711711
712 int64[] sizes = 712 int64[] sizes =
713 {713 {
714 0,714 0,
715 1024,715 1024,
@@ -934,7 +934,7 @@
934 }934 }
935 } while (info != null);935 } while (info != null);
936 file_iter.close();936 file_iter.close();
937 937
938 if (dirs != null)938 if (dirs != null)
939 {939 {
940 while (!dirs.is_empty())940 while (!dirs.is_empty())
@@ -949,7 +949,7 @@
949 {949 {
950 debug ("Previewing: %s", uri);950 debug ("Previewing: %s", uri);
951 Unity.GenericPreview preview = null;951 Unity.GenericPreview preview = null;
952 952
953 string real_uri;953 string real_uri;
954 if (Bookmark.is_bookmark_uri (uri))954 if (Bookmark.is_bookmark_uri (uri))
955 {955 {
@@ -1031,7 +1031,7 @@
1031 {1031 {
1032 total_size = finfo.get_size ();1032 total_size = finfo.get_size ();
1033 preview.add_info (new InfoHint ("size", _("Size"), null, GLib.format_size (total_size)));1033 preview.add_info (new InfoHint ("size", _("Size"), null, GLib.format_size (total_size)));
1034 1034
1035 var open_folder_action = new Unity.PreviewAction ("open-dir", _("Show in Folder"), null);1035 var open_folder_action = new Unity.PreviewAction ("open-dir", _("Show in Folder"), null);
1036 open_folder_action.activated.connect (on_preview_open_folder);1036 open_folder_action.activated.connect (on_preview_open_folder);
1037 preview.add_action (open_folder_action);1037 preview.add_action (open_folder_action);
@@ -1085,7 +1085,7 @@
1085 free_capacity = file_info.get_attribute_uint64 (GLib.FileAttribute.FILESYSTEM_FREE);1085 free_capacity = file_info.get_attribute_uint64 (GLib.FileAttribute.FILESYSTEM_FREE);
10861086
1087 contents_size = total_capacity - free_capacity;1087 contents_size = total_capacity - free_capacity;
1088 1088
1089 } catch (Error e) {1089 } catch (Error e) {
1090 warning ("Failed to query filesystem info: %s", e.message);1090 warning ("Failed to query filesystem info: %s", e.message);
1091 }1091 }
@@ -1157,9 +1157,9 @@
1157 {1157 {
1158 debug (@"Activating: $uri");1158 debug (@"Activating: $uri");
1159 try {1159 try {
1160 if (bookmarks.launch_if_bookmark (uri) || devices.launch_if_device (uri)) 1160 if (bookmarks.launch_if_bookmark (uri) || devices.launch_if_device (uri))
1161 return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH);1161 return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH);
1162 1162
1163 /* this code ensures that a file manager will be used1163 /* this code ensures that a file manager will be used
1164 * * if uri it's a remote location that should be mounted */1164 * * if uri it's a remote location that should be mounted */
1165 var url_type = UrlType.UNKNOWN;1165 var url_type = UrlType.UNKNOWN;
@@ -1234,6 +1234,10 @@
1234 if (excluded_uris != null && origin in excluded_uris) continue;1234 if (excluded_uris != null && origin in excluded_uris) continue;
1235 if (!(origin in origins) && f.is_native () && f.query_exists ())1235 if (!(origin in origins) && f.is_native () && f.query_exists ())
1236 {1236 {
1237 string? path = f.get_path ();
1238 if (path != null && path.contains ("/."))
1239 continue;
1240
1237 var display_name = Path.get_basename (f.get_parse_name ());1241 var display_name = Path.get_basename (f.get_parse_name ());
1238 if (display_name.casefold ().has_prefix (folded_search))1242 if (display_name.casefold ().has_prefix (folded_search))
1239 {1243 {
@@ -1306,7 +1310,8 @@
1306 {1310 {
1307 FileInfo info = file.query_info (check_size ?1311 FileInfo info = file.query_info (check_size ?
1308 ATTRS_TYPE_SIZE_HIDDEN : ATTRS_TYPE_HIDDEN, 0, null);1312 ATTRS_TYPE_SIZE_HIDDEN : ATTRS_TYPE_HIDDEN, 0, null);
1309 if (info.get_is_hidden())1313 string? path = file.get_path ();
1314 if (path != null && path.contains ("/."))
1310 continue;1315 continue;
1311 if (check_size &&1316 if (check_size &&
1312 (info.get_size () < min_size || info.get_size () > max_size))1317 (info.get_size () < min_size || info.get_size () > max_size))
@@ -1356,4 +1361,3 @@
1356 }1361 }
1357 }1362 }
1358} /* namespace */1363} /* namespace */
1359
13601364
=== added file 'tests/manual/misc.txt'
--- tests/manual/misc.txt 1970-01-01 00:00:00 +0000
+++ tests/manual/misc.txt 2012-11-05 11:40:31 +0000
@@ -0,0 +1,14 @@
1Hidden files / dirs are not displayed
2-------------------------------------
3Test that hidden files, hidden folders, or normal files in hidden folders are not displayed in search results.
4
5Setup:
6Create 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.
7Update locatedb (e.g. sudo /etc/cron.daily/mlocate).
8
9Actions:
10Type search queries such as "Foo", "bar", "baz" in the dash search query.
11
12Expected Result:
13Verify none of the newly created hidden files are displayed in the Dash home view with empty search.
14Verify none of the hidden files are displayed after entering a search query.

Subscribers

People subscribed via source and target branches