[tracker-miners/wip/carlosg/miner-fs-fixes: 3/5] tracker-miner-fs: Change nfo:belongsToContainer after updating InformationElement
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/miner-fs-fixes: 3/5] tracker-miner-fs: Change nfo:belongsToContainer after updating InformationElement
- Date: Tue, 19 May 2020 11:13:21 +0000 (UTC)
commit 0faa154daced7b477945a592991277aa1ca99d44
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun May 17 16:57:47 2020 +0200
tracker-miner-fs: Change nfo:belongsToContainer after updating InformationElement
In the case of a folder update (and a rewrite of its nfo:Folder), all elements
that had nfo:belongsToContainer pointing to this resource would be left pointing
to the no longer existing resource.
Ensure those get properly updated, together with the new InformationElement.
src/miners/fs/tracker-miner-files.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index b9fd3fb2d..316aa8f74 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -2438,7 +2438,7 @@ process_file_cb (GObject *object,
TrackerResource *resource, *element_resource;
ProcessFileData *data;
const gchar *mime_type;
- gchar *parent_urn;
+ gchar *parent_urn, *update_relations_sparql = NULL;
gchar *delete_properties_sparql = NULL, *mount_point_sparql;
GFileInfo *file_info;
guint64 time_;
@@ -2538,6 +2538,30 @@ process_file_cb (GObject *object,
mime_type,
is_directory);
+ if (element_resource && is_directory &&
+ tracker_miner_fs_get_urn (TRACKER_MINER_FS (data->miner), file)) {
+ /* Directories need to have the child nfo:FileDataObjects
+ * updated to point to the new nfo:Folder.
+ */
+ update_relations_sparql =
+ g_strdup_printf ("DELETE {"
+ " GRAPH " DEFAULT_GRAPH " {"
+ " ?u nfo:belongsToContainer ?ie "
+ " }"
+ "} INSERT {"
+ " GRAPH " DEFAULT_GRAPH " {"
+ " ?u nfo:belongsToContainer %s "
+ " }"
+ "} WHERE {"
+ " GRAPH " DEFAULT_GRAPH " {"
+ " ?u nfo:belongsToContainer ?ie . "
+ " ?ie nie:isStoredAs <%s> "
+ " }"
+ "}",
+ tracker_resource_get_identifier (element_resource),
+ uri);
+ }
+
mount_point_sparql = update_mount_point_sparql (data);
sparql_update_str = tracker_resource_print_sparql_update (resource, NULL, DEFAULT_GRAPH);
@@ -2552,7 +2576,8 @@ process_file_cb (GObject *object,
DEFAULT_GRAPH);
}
- sparql_str = g_strdup_printf ("%s %s %s %s",
+ sparql_str = g_strdup_printf ("%s %s %s %s %s",
+ update_relations_sparql ? update_relations_sparql : "",
delete_properties_sparql ? delete_properties_sparql : "",
sparql_update_str,
ie_update_str ? ie_update_str : "",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]