Merge lp:~sao/unity-lens-files/ignore-hidden-files into lp:unity-lens-files

Proposed by Oliver Sauder
Status: Merged
Merged at revision: 171
Proposed branch: lp:~sao/unity-lens-files/ignore-hidden-files
Merge into: lp:unity-lens-files
Diff against target: 23 lines (+10/-2)
1 file modified
src/daemon.vala (+10/-2)
To merge this branch: bzr merge lp:~sao/unity-lens-files/ignore-hidden-files
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+59299@code.launchpad.net

Description of the change

Before files are appended to result model checking if there are not hidden.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

This looks mostly good. One catch though is that with the new check we stat() each file twice; first in g_file_query_exists() and then afterwards in g_file_query_info().

If you just drop the file.query_exists() clause and put a continue statement in the catch clause (removing the warning) I think we'll have equivalent behaviour as before while adding the hidden check to that, all still with one stat() only.

review: Needs Fixing
172. By Oliver Sauder

Optimized file hidden and exists test

Revision history for this message
Oliver Sauder (sao) wrote :

True. Adjusted the code as outlined. Did some testing and it seems to work just fine.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Awesome. Thanks Oliver!

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 2011-03-23 12:44:51 +0000
3+++ src/daemon.vala 2011-04-29 17:27:35 +0000
4@@ -1293,9 +1293,17 @@
5
6 /* Don't check existence on non-native files as http:// and
7 * friends are *very* expensive to query */
8- if (file.is_native())
9- if (!file.query_exists ())
10+ if (file.is_native()) {
11+ // hidden files should be ignored
12+ try {
13+ FileInfo info = file.query_info(FILE_ATTRIBUTE_STANDARD_IS_HIDDEN, 0, null);
14+ if (info.get_is_hidden())
15+ continue;
16+ } catch (GLib.Error e) {
17+ // as error occurred file must be missing therefore ignoring it
18 continue;
19+ }
20+ }
21
22 if (section == Section.FOLDERS)
23 {

Subscribers

People subscribed via source and target branches