[tracker-miners/wip/carlosg/moved-files: 2/4] tracker-miner-fs: Handle recursive updates on directory rename ops differently
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/moved-files: 2/4] tracker-miner-fs: Handle recursive updates on directory rename ops differently
- Date: Tue, 15 Sep 2020 13:47:40 +0000 (UTC)
commit d68266cc4c7af9b135b74feb8fabae1445a39fdf
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Sep 15 13:09:54 2020 +0200
tracker-miner-fs: Handle recursive updates on directory rename ops differently
This overly dense query did use to handle all-at-once the nfo:FileDataObject
delete/create to match new URIs and rewiring the nie:isStoredAs relations
so the nie:InformationElements are connected with the brand new
nfo:FileDataObjects.
This however got stuck with older assumptions: 1) It didn't observe the
tracker:FileSystem graph, and 2) it didn't observe the nfo:FileDataObject
shim data in the data graphs.
Since it gets crazy to update and still do all at once, split into 3
more readable queries that do the individual steps, matching also the steps
taken in the non-recursive paths.
Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/136
src/miners/fs/tracker-miner-files.c | 64 ++++++++++++++++++++++++++-----------
1 file changed, 46 insertions(+), 18 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 4b4c25a61..49171ffcd 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -2521,34 +2521,62 @@ miner_files_move_file (TrackerMinerFS *fs,
g_free (container_clause);
if (recursive) {
+ /* Update nie:isStoredAs in the nie:InformationElement */
g_string_append_printf (sparql,
- " DELETE { "
- " ?u a rdfs:Resource . "
- " ?ie1 nie:isStoredAs ?u "
+ "DELETE { "
" GRAPH ?g {"
- " ?ie2 nie:isStoredAs ?u "
+ " ?ie nie:isStoredAs ?f "
" }"
- "} INSERT { "
- " ?new_url a nfo:FileDataObject ; "
- " nie:url ?new_url ; "
- " ?p ?o ."
- " ?ie1 nie:isStoredAs ?new_url . "
+ "} INSERT {"
+ " GRAPH ?g {"
+ " ?ie nie:isStoredAs ?new_url "
+ " }"
+ "} WHERE {"
" GRAPH ?g {"
- " ?ie2 nie:isStoredAs ?new_url . "
+ " ?f a nfo:FileDataObject ."
+ " ?ie nie:isStoredAs ?f ."
+ " BIND (CONCAT (\"%s/\", SUBSTR (STR (?f), STRLEN (\"%s/\") + 1))
AS ?new_url) ."
+ " FILTER (STRSTARTS (STR (?f), \"%s/\")) . "
" }"
+ "}; ",
+ uri, source_uri, source_uri);
+ /* Update tracker:FileSystem nfo:FileDataObject information */
+ g_string_append_printf (sparql,
+ "WITH " DEFAULT_GRAPH " "
+ "DELETE { "
+ " ?f a rdfs:Resource . "
+ "} INSERT { "
+ " ?new_url a nfo:FileDataObject ; "
+ " nie:url ?new_url ; "
+ " ?p ?o . "
"} WHERE { "
- " ?u a rdfs:Resource; "
- " nie:url ?url ; "
+ " ?f a nfo:FileDataObject ;"
" ?p ?o . "
- " OPTIONAL { ?u nie:interpretedAs ?ie1 } "
- " OPTIONAL { GRAPH ?g {"
- " ?u nie:interpretedAs ?ie2 "
- " }}"
- " BIND (CONCAT (\"%s/\", SUBSTR (?url, STRLEN (\"%s/\") + 1)) AS
?new_url) ."
- " FILTER (STRSTARTS (?url, \"%s/\")) . "
+ " BIND (CONCAT (\"%s/\", SUBSTR (STR (?f), STRLEN (\"%s/\") + 1)) AS
?new_url) ."
+ " FILTER (STRSTARTS (STR (?f), \"%s/\")) . "
" FILTER (?p != nie:url) . "
"} ",
uri, source_uri, source_uri);
+ /* Update nfo:FileDataObject in data graphs */
+ g_string_append_printf (sparql,
+ "DELETE { "
+ " GRAPH ?g {"
+ " ?f a rdfs:Resource "
+ " }"
+ "} INSERT {"
+ " GRAPH ?g {"
+ " ?new_url a nfo:FileDataObject ; "
+ " ?p ?o ."
+ " }"
+ "} WHERE {"
+ " GRAPH ?g {"
+ " ?f a nfo:FileDataObject ;"
+ " ?p ?o ."
+ " BIND (CONCAT (\"%s/\", SUBSTR (STR (?f), STRLEN (\"%s/\") + 1))
AS ?new_url) ."
+ " FILTER (STRSTARTS (STR (?f), \"%s/\")) . "
+ " }"
+ "}",
+ uri, source_uri, source_uri);
}
g_free (uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]