Commit 7902523b authored by Martin Kampas's avatar Martin Kampas Committed by Carlos Garnacho

miner-fs: Fix handling files moved soon after creating

Noticed this when executing functional tests for write-back:

(tracker-miner-fs:21288): Tracker-CRITICAL **: Could not execute sparql:
 Subject `(null)' is not in domain `nfo:FileDataObject' of property

This warning happens in item_move() when the source just didn't have
time to be indexed. One example:

copy ("file.txt", "temp_XYZ.file.txt")
 - received G_FILE_MONITOR_EVENT_CREATED ("temp.file.txt")
 - received G_FILE_MONITOR_EVENT_CHANGED ("temp.file.txt")
 - received G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT ("temp.file.txt")
modify ("temp_XYZ.file.txt")
 - received G_FILE_MONITOR_EVENT_CHANGED ("temp.file.txt")
 - received G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT ("temp.file.txt")
mv ("temp_XYZ.file.txt", "file.txt")
 - received G_FILE_MONITOR_EVENT_MOVED ("temp.file.txt", "file.txt")
 - emitted  ITEM_MOVED ("temp.file.txt", "file.txt")

It was already handled in item_move() in past, but removed with eef0e7f3
(libtracker-miner: Remove useless code) after previously misidentified
as useless in scope of ee58e679 (libtracker-miner: Add compat layer for

The comment from ee58e679 """FIXME: This situation shouldn't happen from
a TrackerFileNotifier event""" simply cannot be satisfied: no way to get
"temp.file.txt" indexed before ITEM_MOVED is processed - the file
disappears too fast.
parent e5f565fb
......@@ -1893,6 +1893,23 @@ item_move (TrackerMinerFS *fs,
g_free (source_uri);
g_free (uri);
return retval;
} else if (!source_exists) {
gboolean retval;
/* The source file might not be indexed yet (eg. temporary save
* files that are immediately renamed to the definitive path).
* Deal with those as newly added items.
g_debug ("Source file '%s' not yet in store, indexing '%s' "
"from scratch", source_uri, uri);
retval = item_add_or_update (fs, file, G_PRIORITY_DEFAULT);
g_free (source_uri);
g_free (uri);
g_object_unref (file_info);
return retval;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment