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 750394 - libtracker-miner: Keep a monitor on root index tree files on deletion
libtracker-miner: Keep a monitor on root index tree files on deletion
Status: RESOLVED FIXED
Product: tracker
Classification: Core
Component: Miners
unspecified
Other All
: Normal normal
: ---
Assigned To: tracker-general
tracker-general
Depends on:
Blocks:
 
 
Reported: 2015-06-04 12:54 UTC by Philip Withnall
Modified: 2015-07-06 08:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libtracker-miner: Keep a monitor on root index tree files on deletion (5.42 KB, patch)
2015-06-04 12:54 UTC, Philip Withnall
none Details | Review
libtracker-miner: Keep a monitor on root index tree files on deletion (5.89 KB, patch)
2015-07-06 08:42 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2015-06-04 12:54:18 UTC
See the attached patch. This can be reproduced with something like:
   $ gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories ['&MUSIC']
   $ tracker-search 'some album name from your music'  # expect results
   $ mv ~/Music ~/Music-moved
   $ tracker-search 'some album name from your music'  # expect nothing
   $ mv ~/Music-moved ~/Music
   $ tracker-search 'some album name from your music'  # expect results, actually get nothing (bug)
Comment 1 Philip Withnall 2015-06-04 12:54:21 UTC
Created attachment 304579 [details] [review]
libtracker-miner: Keep a monitor on root index tree files on deletion

If Tracker is running with some index-recursive-directories set (for
example, ~/Music), and one of those directories is moved, then the file
monitor watching for its existence is deleted. This means that if it is
then moved back to the location listed in index-recursive-directories,
its renewed existence is not detected, and its contents are not
re-indexed.

Fix this by keeping a monitor around on a directory if that directory is
listed as an index tree root, even if the directory is deleted.
Comment 2 Carlos Garnacho 2015-07-04 20:17:30 UTC
Review of attachment 304579 [details] [review]:

Nice catch Philip :). Just a minor comment, feel free to push after that.

::: src/libtracker-miner/tracker-monitor.c
@@ +1606,3 @@
 	while (g_hash_table_iter_next (&iter, &iter_file, &iter_file_monitor)) {
 		if (!g_file_has_prefix (iter_file, file) &&
+		    !(remove_top_level && g_file_equal (iter_file, file))) {

The amount of double negatives makes my head explode a bit here :). Would be really nice if you could split this into a separate inline is_file_contained(file,child,include_parent) or somesuch.

Note to self, we should get rid of the giant hashtable and store info as TrackerFileSystem data at some point, it will surely help on performance here.
Comment 3 Philip Withnall 2015-07-06 08:42:35 UTC
Created attachment 306898 [details] [review]
libtracker-miner: Keep a monitor on root index tree files on deletion

If Tracker is running with some index-recursive-directories set (for
example, ~/Music), and one of those directories is moved, then the file
monitor watching for its existence is deleted. This means that if it is
then moved back to the location listed in index-recursive-directories,
its renewed existence is not detected, and its contents are not
re-indexed.

Fix this by keeping a monitor around on a directory if that directory is
listed as an index tree root, even if the directory is deleted.
Comment 4 Philip Withnall 2015-07-06 08:43:19 UTC
t push pwith :wip	# Bug 750394 - libtracker-miner: Keep a monitor on root index tree files on deletion - NEW
Thanks for the review. Pushed the updated patch with that prefix logic split out and commented.

Attachment 306898 [details] pushed as 0ca8361 - libtracker-miner: Keep a monitor on root index tree files on deletion