After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 696802 - Pickup additional directories configured in Tracker
Pickup additional directories configured in Tracker
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
3.9.x
Other All
: Normal normal
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
: 731652 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-03-28 17:55 UTC by Elad Alfassa
Modified: 2014-06-16 08:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add all tracker directories, using the same way as gnome-documents (2.74 KB, patch)
2014-03-06 19:57 UTC, Chunyang Xu
reviewed Details | Review
Fix patch according to the suggestions (2.97 KB, patch)
2014-03-07 11:32 UTC, Chunyang Xu
needs-work Details | Review
query-builder: Add Tracker directories (3.35 KB, patch)
2014-03-14 15:53 UTC, Chunyang Xu
none Details | Review
Just update commit message (3.38 KB, patch)
2014-03-14 16:38 UTC, Chunyang Xu
reviewed Details | Review
query-builder: Add additional directories configured in Tracker (2.98 KB, patch)
2014-03-17 10:37 UTC, Debarshi Ray
committed Details | Review

Description Elad Alfassa 2013-03-28 17:55:47 UTC
As a web developer, I keep a lot of sprites/website related (usually low-res) images, most of them in my Downloads folder. My Downloads folder is indexed by tracker for faster searching, so as a result when I open photos most of what I see is upscaled low-res icons from various web projects I'm working on, instead of my actual photos which are kept either in my Pictures directory and my Dropbox "Camera Sync" directory.

I see two approaches for fixing this problem:
1) Prioritize photos in the Pictures directory so that they appear first in the list
2) Make it possible to configure which folders to display photos from.
Comment 1 Debarshi Ray 2013-08-09 12:29:31 UTC
Adding Jon to CC because we discussed this briefly at GUADEC. We might want to leave out ~/Downloads. Perhaps the same for gnome-documents too?
Comment 2 Debarshi Ray 2014-03-03 14:06:10 UTC
*** Bug 709366 has been marked as a duplicate of this bug. ***
Comment 3 Chunyang Xu 2014-03-06 08:20:13 UTC
(In reply to comment #0)
> As a web developer, I keep a lot of sprites/website related (usually low-res)
> images, most of them in my Downloads folder. My Downloads folder is indexed by
> tracker for faster searching, so as a result when I open photos most of what I
> see is upscaled low-res icons from various web projects I'm working on, instead
> of my actual photos which are kept either in my Pictures directory and my
> Dropbox "Camera Sync" directory.
> 
> 2) Make it possible to configure which folders to display photos from.

gnome-photos and gnome-documents use tracker for fetching metadata, you can choose which folders to be tracked using tracker-preferences. ie. add ~/Dropbox/Camera Sync, remove ~/Download for you. 

But gnome-photos only support three folders (Desktop, Download and Pictures), this is a real bug.

(In reply to comment #1)
> Adding Jon to CC because we discussed this briefly at GUADEC. We might want to
> leave out ~/Downloads. Perhaps the same for gnome-documents too?

gnome-documents works fine. If you want to leave out ~/Downloads, use tracker-perferences.
Comment 4 Chunyang Xu 2014-03-06 19:45:41 UTC
> > Adding Jon to CC because we discussed this briefly at GUADEC. We might want to
> > leave out ~/Downloads. Perhaps the same for gnome-documents too?
> 
> gnome-documents works fine. If you want to leave out ~/Downloads, use
> tracker-perferences.

The only less important problem is that Photos/Document will ignore pictures or documents in XDG directories except three special directories.
Comment 5 Chunyang Xu 2014-03-06 19:57:14 UTC
Created attachment 271139 [details] [review]
Add all tracker directories, using the same way as gnome-documents

please review, thanks!
Comment 6 Debarshi Ray 2014-03-06 20:22:03 UTC
Review of attachment 271139 [details] [review]:

Thanks for the patch.

While we do acknowledge the original problem in the bug report, we are still undecided on the solution. One option is to have "import to photos" action in, say Web, which will add the item to the Tracker DB in a way that it will show up in the application. Maybe by copying it over to ~/Pictures. At that point we can stop looking at ~/Downloads.

The other alternative that has been thrown around is to have an option to monitor other locations.
Comment 7 Chunyang Xu 2014-03-07 01:00:23 UTC
I think the original problem is that user wants Photos to ignore ~/Downloads and index ~/Dropbox/Camera\ Sync/, but can't. 

In this case, I suggest using tracker-preferences to meet this need.  Photos should works fine just like Documents, but I found it not to be so. Photos correctly leaves out ~/Download but still not index ~/Dropbox/Camera\ Sync/. This is a bug of Photos. It seems that it is a omission while porting from javascript to C. And my patch is only for this bug. 

I'm not sure whether it is necessary to add an action for download pictures to ~/Picture instead of ~/Download or an option to monitor other folders, since Documents and Music both don't have these.
Comment 8 Chunyang Xu 2014-03-07 01:01:15 UTC
I think the original problem is that user wants Photos to ignore ~/Downloads and index ~/Dropbox/Camera\ Sync/, but can't. 

In this case, I suggest using tracker-preferences to meet this need.  Photos should works fine just like Documents, but I found it not to be so. Photos correctly leaves out ~/Download but still not index ~/Dropbox/Camera\ Sync/. This is a bug of Photos. It seems that it is a omission while porting from javascript to C. And my patch is only for this bug. 

I'm not sure whether it is necessary to add an action for download pictures to ~/Picture instead of ~/Download or an option to monitor other folders, since Documents and Music both don't have these.
Comment 9 Chunyang Xu 2014-03-07 01:01:22 UTC
I think the original problem is that user wants Photos to ignore ~/Downloads and index ~/Dropbox/Camera\ Sync/, but can't. 

In this case, I suggest using tracker-preferences to meet this need.  Photos should works fine just like Documents, but I found it not to be so. Photos correctly leaves out ~/Download but still not index ~/Dropbox/Camera\ Sync/. This is a bug of Photos. It seems that it is a omission while porting from javascript to C. And my patch is only for this bug. 

I'm not sure whether it is necessary to add an action for download pictures to ~/Picture instead of ~/Download or an option to monitor other folders, since Documents and Music both don't have these.
Comment 10 Chunyang Xu 2014-03-07 01:01:31 UTC
I think the original problem is that user wants Photos to ignore ~/Downloads and index ~/Dropbox/Camera\ Sync/, but can't. 

In this case, I suggest using tracker-preferences to meet this need.  Photos should works fine just like Documents, but I found it not to be so. Photos correctly leaves out ~/Download but still not index ~/Dropbox/Camera\ Sync/. This is a bug of Photos. It seems that it is a omission while porting from javascript to C. And my patch is only for this bug. 

I'm not sure whether it is necessary to add an action for download pictures to ~/Picture instead of ~/Download or an option to monitor other folders, since Documents and Music both don't have these.
Comment 11 Chunyang Xu 2014-03-07 01:01:39 UTC
I think the original problem is that user wants Photos to ignore ~/Downloads and index ~/Dropbox/Camera\ Sync/, but can't. 

In this case, I suggest using tracker-preferences to meet this need.  Photos should works fine just like Documents, but I found it not to be so. Photos correctly leaves out ~/Download but still not index ~/Dropbox/Camera\ Sync/. This is a bug of Photos. It seems that it is a omission while porting from javascript to C. And my patch is only for this bug. 

I'm not sure whether it is necessary to add an action for download pictures to ~/Picture instead of ~/Download or an option to monitor other folders, since Documents and Music both don't have these.
Comment 12 Chunyang Xu 2014-03-07 01:28:45 UTC
I‘m sorry for these redundant comments caused by a strange network problem.
Comment 13 Debarshi Ray 2014-03-07 09:05:17 UTC
(In reply to comment #7)

So reading the code again, Documents does indeed pickup locations from Tracker's settings these days. This was added somewhat recently. Sorry about that.

> I think the original problem is that user wants Photos to ignore ~/Downloads
> and index ~/Dropbox/Camera\ Sync/, but can't. 
> 
> In this case, I suggest using tracker-preferences to meet this need.  Photos
> should works fine just like Documents, but I found it not to be so. Photos
> correctly leaves out ~/Download but still not index ~/Dropbox/Camera\ Sync/.

But this part is confusing. I think Documents only picks up more locations from Tracker's settings. I can't see how it would leave out ~/Downloads. Looks pretty hard coded to me: https://git.gnome.org/browse/gnome-documents/tree/src/search.js#n345

Moreover your patch also would not omit ~/Downloads. It would only allow the user to add extra locations. Right?

> I'm not sure whether it is necessary to add an action for download pictures to
> ~/Picture instead of ~/Download or an option to monitor other folders, since
> Documents and Music both don't have these.

They will eventually have something. As I told you, we are undecided how to handle the ~/Downloads use case. Remember that the whole point of Documents, Photos and the other content applications is to let the user avoid dealing with files and directories.

PS: the Search panel is another alternative to tracker-preferences.
Comment 14 Debarshi Ray 2014-03-07 09:17:10 UTC
Review of attachment 271139 [details] [review]:

::: src/photos-query-builder.c
@@ +38,3 @@
+static const gchar *TRACKER_SCHEMA = "org.freedesktop.Tracker.Miner.Files";
+static const gchar *TRACKER_KEY_RECURSIVE_DIRECTORIES = "index-recursive-directories";
+

We separate sections in a source file with 2 newlines. So add another one.

@@ +344,3 @@
 {
+  gchar *filter = NULL;
+  GSettings *settings = g_settings_new (TRACKER_SCHEMA);

I think settings will get leaked because I don't see a 'g_object_unref (settings)'. Also, put the function call on a separate statement than the definition for consistency with the rest of the code.

@@ +348,3 @@
+  gchar *tracker_uri = NULL;
+
+  for (; *tracker_dir != NULL; tracker_dir++)

I would suggest using 'for (i = 0; tracker_dirs[i] != NULL; i++)', where i is a guint. It would be consistent with the pattern used elsewhere. See photos-search-provider.c and related files.

@@ +358,3 @@
+       {
+         tracker_uri = photos_query_builder_convert_path_to_uri (*tracker_dir);
+         filter = g_strconcat (g_strdup_printf (" || fn:contains (nie:url (?urn), \"%s\")", tracker_uri),

It is better to use ' instead of " to quote strings inside SPARQL. First, you don't need to escape ', and using it consistently makes it easier to copy paste the queries from the DEBUG output into tracker-sparql(1).

I have fixed the existing code to consistently use '.

@@ +369,2 @@
   const gchar *path;
   gchar *pictures_uri;

These need to be moved to the top of the file. We do not do variable definitions in the middle of the block.
Comment 15 Chunyang Xu 2014-03-07 10:32:33 UTC
(In reply to comment #13)

> But this part is confusing. I think Documents only picks up more locations from
> Tracker's settings. I can't see how it would leave out ~/Downloads. Looks
> pretty hard coded to me:
> https://git.gnome.org/browse/gnome-documents/tree/src/search.js#n345
> 
> Moreover your patch also would not omit ~/Downloads. It would only allow the
> user to add extra locations. Right?
> 

Yes, the user still have to use Tracker‘s configuration tool to omit/add folders for Photos. 

> They will eventually have something. As I told you, we are undecided how to
> handle the ~/Downloads use case. Remember that the whole point of Documents,
> Photos and the other content applications is to let the user avoid dealing with
> files and directories.
> 
> PS: the Search panel is another alternative to tracker-preferences.

Now, I prefer to add an option to customize which folders Photos will monitor.
Comment 16 Chunyang Xu 2014-03-07 11:32:02 UTC
Created attachment 271201 [details] [review]
Fix patch according to the suggestions

Thanks for the review. I've fixed the patch according to the suggestions.
Comment 17 Debarshi Ray 2014-03-14 10:46:13 UTC
Review of attachment 271201 [details] [review]:

Thanks for the patch, Chunyang! This is better.

::: src/photos-query-builder.c
@@ +376,2 @@
   gchar *pictures_uri;
+  const gchar *path;

This is a spurious change. 'const gchar *path;' got removed and added back.

@@ +419,3 @@
   g_free (download_uri);
   g_free (pictures_uri);
+  g_free (tracker_dir);

We need g_strfreev instead of g_free because tracker_dir is a NULL terminated array of strings.

@@ +420,3 @@
   g_free (pictures_uri);
+  g_free (tracker_dir);
+  g_free (tracker_uri);

tracker_uri should be freed inside the for loop.
Comment 18 Debarshi Ray 2014-03-14 10:56:08 UTC
Review of attachment 271201 [details] [review]:

::: src/photos-query-builder.c
@@ +387,3 @@
+          continue;
+        }
+      else

We don't need the else branch. It is enough to have the continue above.

@@ +392,3 @@
+         filter = g_strconcat (g_strdup_printf (" || fn:contains (nie:url (?urn), '%s')", tracker_uri),
+                               filter,
+                               NULL);

The previous buffer pointed to by filter and the buffer returned by g_strdup_printf are getting leaked. The easiest (and best) way out is to use GString. See photos-tracker-change-monitor.c for an example.
Comment 19 Chunyang Xu 2014-03-14 15:53:16 UTC
Created attachment 271917 [details] [review]
query-builder: Add Tracker directories

Fix patch according the suggestions.
Comment 20 Elad Alfassa 2014-03-14 15:55:15 UTC
If Photos will display photos from all tracker directories then the bug I described when I opened this one still applies. I want tracker to index my Downloads folder, for fast searching, but I do NOT want Photos displaying photos from there.
Comment 21 Debarshi Ray 2014-03-14 16:20:06 UTC
(In reply to comment #20)
> If Photos will display photos from all tracker directories then the bug I
> described when I opened this one still applies. I want tracker to index my
> Downloads folder, for fast searching, but I do NOT want Photos displaying
> photos from there.

Yes, since this one got hijacked, lets use bug 709366 for that.
Comment 22 Debarshi Ray 2014-03-14 16:21:40 UTC
Changing the summary to reflect reality.
Comment 23 Chunyang Xu 2014-03-14 16:38:47 UTC
Created attachment 271922 [details] [review]
Just update commit message
Comment 24 Debarshi Ray 2014-03-17 10:36:35 UTC
Review of attachment 271922 [details] [review]:

This looks good, but I prefer the general structure of your previous patches. eg., we don't really need GString to create the whole string but only the parts of it with the Tracker locations.
Comment 25 Debarshi Ray 2014-03-17 10:37:42 UTC
Created attachment 272131 [details] [review]
query-builder: Add additional directories configured in Tracker

I tweaked your previous patch a bit and added the GString bits.
Comment 26 Debarshi Ray 2014-03-17 10:42:04 UTC
Thanks for your work on this Chunyang. Well done!
Comment 27 Debarshi Ray 2014-06-16 08:34:46 UTC
*** Bug 731652 has been marked as a duplicate of this bug. ***