"Unable to insert multiple values for subject ... and single valued property `nie:contentCreated'" warnings
The chain of events leading to these errors are:
- User re-edits the file, which would yield a different creation date, etc
- Tracker-miner-fs picks up the file update, and does this query in preparation for re-extraction:
DELETE {
GRAPH <%s> {
<%s> ?p ?o"
}
}
WHERE {
GRAPH <%s> {
<%s> ?p ?o
FILTER (?p != rdf:type && ?p != nie:contentCreated)
}
}
DELETE {
<%s> nie:url ?o
} WHERE {
<%s> nie:url ?o
}
Thus, basically delete all data from the file, but preserving prior nie:contentCreated
and other minimally essential data.
- Later, when
tracker-extract
gets to do its job, it will try to ensure single-valued fields are unset before extraction, eg:
DELETE {
<%s>
nfo:width ?nfo_width ;
nmm:dlnaProfile ?nmm_dlnaProfile ;
nfo:height ?nfo_height ;
nmm:dlnaMime ?nmm_dlnaMime
}
WHERE {
<%s>
nfo:width ?nfo_width ;
nmm:dlnaProfile ?nmm_dlnaProfile ;
nfo:height ?nfo_height ;
nmm:dlnaMime ?nmm_dlnaMime
}
This is when things start going south, such a delete will attempt to delete all those 4 metadata items, but only if all those 4 exist. As they don't there is no real match and this query does nothing.
- The next query will try to insert metadata (nie:contentCreated included) while the previous value is still around. And as the nie:contentCreated did actually change (because the user edited the file), it will fail.
The solution to all of this is making updates that can delete individual values, the first obvious approach is:
DELETE WHERE {
OPTIONAL { <%s> nfo:width ?nfo_width } .
OPTIONAL { <%s> nmm:dlnaProfile ?nmm_dlnaProfile } .
OPTIONAL { <%s> nfo:height ?nfo_height } .
OPTIONAL { <%s> nmm:dlnaMime ?nmm_dlnaMime } .
}
But that translates to queries that may easily make the SQLite parser to overflow (The more optionals, the more joins). The next approach is actually decomposing that into multiple queries, that are executed sequentially:
DELETE WHERE { <%s> nfo:width ?nfo_width }
DELETE WHERE { <%s> nmm:dlnaProfile ?nmm_dlnaProfile }
DELETE WHERE { <%s> nfo:height ?nfo_height }
DELETE WHERE { <%s> nmm:dlnaMime ?nmm_dlnaMime }
That does work as expected with no drawbacks, so was chosen as the fix.