Commit 08f4af62 authored by Sam Thursfield's avatar Sam Thursfield

tracker-extract-text: Correctly report errors back to the caller

The tracker_extract_get_metadata() function should return FALSE if
an error occurs reading the file. The tracker-extract-text module would
return TRUE in all cases.

This was causing intermittent failures in the functional-tests, as the
following situation could occur:

  1. file2.txt is created
  2. tracker-miner-fs sees file2.txt and processes it
  3. file2.txt is deleted (or moved into an unmonitored directory)
  4. tracker-miner-fs sees the deletion and removes its resource from
     the store
  5. tracker-extract sees the created notification for file2.txt and
     tries to process it
  6. the tracker_extract_get_metadata() incorrectly returns TRUE
     (success), so tracker-extract recreates the deleted resource

This problem was being detected in the functional tests and was
causing intermittent failures.

This hopefully fixes: #56
parent 13948fda
Pipeline #78888 passed with stage
in 1 minute and 27 seconds
......@@ -46,10 +46,7 @@ get_file_content (GFile *file,
gchar *text, *uri, *path;
int fd;
/* If no content requested, return */
if (n_bytes == 0) {
return NULL;
}
g_return_val_if_fail (n_bytes > 0, NULL);
uri = g_file_get_uri (file);
......@@ -85,12 +82,20 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
{
TrackerResource *metadata;
TrackerConfig *config;
gchar *content;
gsize n_bytes;
gchar *content = NULL;
config = tracker_main_get_config ();
content = get_file_content (tracker_extract_info_get_file (info),
tracker_config_get_max_bytes (config));
n_bytes = tracker_config_get_max_bytes (config);
if (n_bytes > 0) {
content = get_file_content (tracker_extract_info_get_file (info), n_bytes);
if (content == NULL) {
/* An error occurred, perhaps the file was deleted. */
return FALSE;
}
}
metadata = tracker_resource_new (NULL);
tracker_resource_add_uri (metadata, "rdf:type", "nfo:PlainTextDocument");
......
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