[tracker-miners/wip/carlosg/batches-and-resources: 26/31] libtracker-miner: Move function to determine IRI/bnode to TrackerMinerFS
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/batches-and-resources: 26/31] libtracker-miner: Move function to determine IRI/bnode to TrackerMinerFS
- Date: Fri, 11 Dec 2020 10:55:04 +0000 (UTC)
commit c7e266f2e892e7f82a20377af0f81c4fd81e34b2
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Dec 4 23:42:46 2020 +0100
libtracker-miner: Move function to determine IRI/bnode to TrackerMinerFS
We can do better checks about folders there, with better access to
SPARQL and task queues.
src/libtracker-miner/tracker-miner-fs.c | 38 ++++++++++++++++++++-------------
src/libtracker-miner/tracker-miner-fs.h | 9 ++++----
src/miners/fs/tracker-miner-files.c | 34 ++++++-----------------------
3 files changed, 34 insertions(+), 47 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 503d7421b..36955b21c 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2260,20 +2260,7 @@ tracker_miner_fs_get_throttle (TrackerMinerFS *fs)
return fs->priv->throttle;
}
-/**
- * tracker_miner_fs_get_folder_urn:
- * @fs: a #TrackerMinerFS
- * @file: a #GFile
- *
- * If the item exists in the store, this function retrieves
- * the URN of the given #GFile
-
- * If @file doesn't exist in the store yet, %NULL will be returned.
- *
- * Returns: The URN containing the data associated
- * to @file, or %NULL.
- **/
-const gchar *
+static const gchar *
tracker_miner_fs_get_folder_urn (TrackerMinerFS *fs,
GFile *file)
{
@@ -2374,7 +2361,7 @@ tracker_miner_fs_get_data_provider (TrackerMinerFS *fs)
return fs->priv->data_provider;
}
-gchar *
+static gchar *
tracker_miner_fs_get_file_bnode (TrackerMinerFS *fs,
GFile *file,
gboolean create)
@@ -2398,3 +2385,24 @@ tracker_miner_fs_get_file_bnode (TrackerMinerFS *fs,
return NULL;
}
+
+gchar *
+tracker_miner_fs_get_identifier (TrackerMinerFS *miner,
+ GFile *file,
+ gboolean new_resource,
+ gboolean *is_iri)
+{
+ const gchar *urn;
+
+ if (is_iri)
+ *is_iri = FALSE;
+
+ urn = tracker_miner_fs_get_folder_urn (miner, file);
+ if (urn) {
+ if (is_iri)
+ *is_iri = TRUE;
+ return g_strdup (urn);
+ }
+
+ return tracker_miner_fs_get_file_bnode (miner, file, new_resource);
+}
diff --git a/src/libtracker-miner/tracker-miner-fs.h b/src/libtracker-miner/tracker-miner-fs.h
index e39e08798..691ffe1fd 100644
--- a/src/libtracker-miner/tracker-miner-fs.h
+++ b/src/libtracker-miner/tracker-miner-fs.h
@@ -164,11 +164,10 @@ void tracker_miner_fs_notify_finish (TrackerMinerFS *f
GError *error);
/* URNs */
-const gchar *tracker_miner_fs_get_folder_urn (TrackerMinerFS *fs,
- GFile *file);
-gchar * tracker_miner_fs_get_file_bnode (TrackerMinerFS *fs,
- GFile *file,
- gboolean create);
+gchar * tracker_miner_fs_get_identifier (TrackerMinerFS *miner,
+ GFile *file,
+ gboolean new_resource,
+ gboolean *is_iri);
/* Progress */
gboolean tracker_miner_fs_has_items_to_process (TrackerMinerFS *fs);
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 9371fc26d..1a76bba2c 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -1958,27 +1958,6 @@ index_applications_changed_cb (GObject *gobject,
}
}
-static gchar *
-folder_urn_or_bnode (TrackerMinerFiles *mf,
- GFile *file,
- gboolean new_bnode,
- gboolean *is_iri)
-{
- const gchar *urn;
-
- if (is_iri)
- *is_iri = FALSE;
-
- urn = tracker_miner_fs_get_folder_urn (TRACKER_MINER_FS (mf), file);
- if (urn) {
- if (is_iri)
- *is_iri = TRUE;
- return g_strdup (urn);
- }
-
- return tracker_miner_fs_get_file_bnode (TRACKER_MINER_FS (mf), file, new_bnode);
-}
-
static void
miner_files_add_to_datasource (TrackerMinerFiles *mf,
GFile *file,
@@ -1986,8 +1965,9 @@ miner_files_add_to_datasource (TrackerMinerFiles *mf,
TrackerResource *element_resource)
{
TrackerIndexingTree *indexing_tree;
+ TrackerMinerFS *fs = TRACKER_MINER_FS (mf);
- indexing_tree = tracker_miner_fs_get_indexing_tree (TRACKER_MINER_FS (mf));
+ indexing_tree = tracker_miner_fs_get_indexing_tree (fs);
if (tracker_indexing_tree_file_is_root (indexing_tree, file)) {
tracker_resource_set_relation (resource, "nie:dataSource", element_resource);
@@ -1998,7 +1978,7 @@ miner_files_add_to_datasource (TrackerMinerFiles *mf,
root = tracker_indexing_tree_get_root (indexing_tree, file, NULL);
if (root)
- identifier = folder_urn_or_bnode (mf, root, FALSE, NULL);
+ identifier = tracker_miner_fs_get_identifier (fs, root, FALSE, NULL);
if (identifier)
tracker_resource_set_uri (resource, "nie:dataSource", identifier);
@@ -2038,7 +2018,8 @@ miner_files_create_folder_information_element (TrackerMinerFiles *miner,
gchar *urn, *uri;
/* Preserve URN for nfo:Folders */
- urn = folder_urn_or_bnode (miner, file, TRUE, NULL);
+ urn = tracker_miner_fs_get_identifier (TRACKER_MINER_FS (miner),
+ file, TRUE, NULL);
resource = tracker_resource_new (urn);
g_free (urn);
@@ -2124,7 +2105,7 @@ miner_files_process_file (TrackerMinerFS *fs,
tracker_resource_add_uri (resource, "rdf:type", "nfo:FileDataObject");
parent = g_file_get_parent (file);
- parent_urn = folder_urn_or_bnode (TRACKER_MINER_FILES (fs), parent, FALSE, NULL);
+ parent_urn = tracker_miner_fs_get_identifier (fs, parent, FALSE, NULL);
g_object_unref (parent);
if (parent_urn) {
@@ -2333,8 +2314,7 @@ miner_files_move_file (TrackerMinerFS *fs,
gchar *new_parent_id;
gboolean is_iri;
- new_parent_id = folder_urn_or_bnode (TRACKER_MINER_FILES (fs),
- new_parent, FALSE, &is_iri);
+ new_parent_id = tracker_miner_fs_get_identifier (fs, new_parent, FALSE, &is_iri);
if (new_parent_id) {
container_clause =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]