summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* libtracker-sparql: Take TrackerNotifier weak ref when emitting eventsCarlos Garnacho2023-05-151-10/+25
| | | | | Avoid keeping a hard ref while notifier events are being dispatched, this makes the TrackerNotifier lifetime completely in control of the user.
* libtracker-sparql: Keep statement in cache event structCarlos Garnacho2023-05-151-21/+26
| | | | Instead of figuring out from the subscription later on.
* libtracker-sparql: Pass service through TrackerNotifier event cache structCarlos Garnacho2023-05-151-19/+15
| | | | | Figure the service IRI early on cache struct creation, so we do not need to rely on subscription+notifier to create it afterwards.
* libtracker-sparql: Pass cancellable through notifier event cache structCarlos Garnacho2023-05-151-5/+9
| | | | | Avoid poking the notifier for this, passing the cancellable for async operations with the cache struct itself.
* libtracker-sparql: Pass TrackerNotifier explicitly when flushing eventsCarlos Garnacho2023-05-153-5/+6
| | | | | Try to decouple the dependency on cache->notifier in code. This is a good start.
* libtracker-sparql: Check cancellable more often in TrackerNotifierCarlos Garnacho2023-05-151-1/+7
| | | | | | | | While handling the URN query cursor, we did not check the cancellable and went all through with it, even if TrackerNotifier finalization paths might have cancelled the task. This could not happen in practice since the cache struct takes a reference on the TrackerNotifier, but will happen with future commits.
* libtracker-sparql: Improve threading guarantees of TrackerNotifierCarlos Garnacho2023-05-151-4/+18
| | | | | | | | | | | | Make the TrackerNotifier::events signal ensured to be emitted in the same main context that created the TrackerNotifier. This is coherent with other threaded objects that have communication through signals (e.g. GDBusProxy). Notably, it is already expected to behave this way in tracker-miners. Since the tracker-miner-fs-3 D-Bus endpoint is managed on a distinct context/thread that should also handle the proxying of notifier events without involvement of the main thread/context.
* bus: Plug leakCarlos Garnacho2023-05-131-1/+1
| | | | | | Parameters bound to a bus TrackerSparqlStatement would be leaked on statement execution. The GVariants are already owned by the hashtable.
* Merge branch 'wip/carlosg/strftime-format-detection' into 'master'Carlos Garnacho2023-05-121-2/+2
|\ | | | | | | | | | | | | build: Detect appropriate strftime() year modifier at build time Closes #402 See merge request https://gitlab.gnome.org/GNOME/tracker/-/merge_requests/593
| * build: Detect appropriate strftime() year modifier at build timeCarlos Garnacho2023-05-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Different libc implementations (or different platforms) have different bugs. Even though %Y is documented as a 4-digit number, and %C as year/100 in a [00-99] range, they both crap out with years under 1000, using respectively 3 and 1 digits. This would be typically task for a width modifier (e.g. %4Y, or %2C), but that was conversely found to break NixOS on Darwin. Since the existing libc bugs paint us to a corner, detect an appropriate modifier at build time to get a 4-digit year to get true ISO 8601 in our supported [0001-9999] year range. Closes: https://gitlab.gnome.org/GNOME/tracker/-/issues/402
* | remote: Fix possible double freeCarlos Garnacho2023-05-041-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | In case of error reading from the input stream, we would propagate the error through the GTask and break, falling through paths that also try to return and free the task. Handle the task entirely at the end of the function, based on the return value. We still need to close the input stream and soup message in any case. CID: #1517496
* | core: Avoid possible buffer overrunsCarlos Garnacho2023-05-041-1/+3
| | | | | | | | | | | | | | | | In some circumstances we may pass -1 as len to g_strndup(), that does not follow the "-1 means strlen()" convention. Do this ourselves. CIDs: #1530151, #1530152
* | core: Handle possible NULL values converting GValues to parser tokensCarlos Garnacho2023-05-011-5/+9
|/ | | | | | These might get to happen in the right circumstances, from the looks of it. Possibly fixes https://retrace.fedoraproject.org/faf/reports/688192/ and similar automated reports.
* direct: Prune only content of correctly finished batchesCarlos Garnacho2023-04-091-2/+1
| | | | | | | | | | | | | | | | | Commit 944988326 attempted made finished batches cheap to keep in memory, for languages where we don't have full control of object lifetime (e.g. GJS). This however broke tracker-miner-fs-3 handling of failures, since that tries to peek at TrackerResources that were already disposed by the TrackerBatch being cleared of content, in order to retry, or report for `tracker3 status`. In order to fix that and keep the improvement for the common case (i.e. success), only clear the TrackerBatch contents if the operation finished successfully. Fixes: 944988326 ("libtracker-sparql/direct: Prune content of already executed batches")
* core: Handle FTS search terms individuallyCarlos Garnacho2023-03-201-6/+6
| | | | | | | | | | | | | | Commit da9eb9a07c hid the internal FTS syntax as an implementation detail, but it did so by making the full search string a single term, so multiple input words had to also appear consecutively in the searched text to be considered a match. Bring back the flexibility in order/distance of the looked up words by using a SQLite helper function to split FTS search terms. This still results in the FTS syntax being hidden away, but splits the input words so that each becomes its own search term. Fixes: da9eb9a07c ("libtracker-data: Do not expose FTS5 syntax through fts:match")
* core: Add helper SQLite function to tokenize FTS search termsCarlos Garnacho2023-03-201-0/+62
| | | | | | | This function splits the search terms, and surrounds each of them with double quotes so they are taken as individual literal strings to be matched, quotes explicitly present in the search string are observed and handled as a single search term, and implicitly closed in unfinished.
* Merge branch 'wip/carlosg/more-leak-fixes' into 'master'Carlos Garnacho2023-03-052-0/+3
|\ | | | | | | | | Plug some leaks See merge request https://gitlab.gnome.org/GNOME/tracker/-/merge_requests/582
| * libtracker-sparql: Plug possible leak loading statements from GResourceCarlos Garnacho2023-03-051-0/+2
| | | | | | | | | | When juggling with both update/select errors, we might be leaking one if the latter call succeeded.
| * direct: Plug leak in tracker_sparql_statement_update_async()Carlos Garnacho2023-03-051-0/+1
| | | | | | | | | | The async process takes a ref on the hashtable, so dispose our own reference here.
* | libtracker-common: Fix building Tracker as a subprojectCarlos Garnacho2023-03-052-1/+2
| | | | | | | | | | | | | | | | | | The module lookup is currently based to the top builddir, which might differ is Tracker is being built as a subproject. Make it dependent on the current build dir (i.e. the directory the module will be built to), so it works also on those situations. Fixes: a4f9885a15d ("libtracker-common: Convert unicode parser to a GModule")
* | Merge branch 'wip/carlosg/gi-docgen-take-2' into 'master'Sam Thursfield2023-03-0326-917/+1162
|\ \ | | | | | | | | | | | | Migrate docs to gi-docgen (Take 2) See merge request https://gitlab.gnome.org/GNOME/tracker/-/merge_requests/580
| * | libtracker-sparql: Update library API documentationCarlos Garnacho2023-02-2725-910/+1152
| | | | | | | | | | | | | | | | | | Port references and links to the gi-docgen format, and while at it flesh out some more documentation and adjust formatting to look better with the gi-docgen templates.
| * | build: Ensure to generate enum types for the error domainCarlos Garnacho2023-02-271-1/+3
| | | | | | | | | | | | This is required for correct introspection of our error domain.
| * | libtracker-sparql: Do not use volatile to register DBus errorsCarlos Garnacho2023-02-271-6/+7
| | | | | | | | | | | | | | | The documentation of g_dbus_error_register_error_domain() says we should not use one.
* | | Merge branch 'wip/carlosg/modular-unicode-lib' into 'master'Sam Thursfield2023-03-0316-768/+763
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | Make unicode library a module Closes #396 See merge request https://gitlab.gnome.org/GNOME/tracker/-/merge_requests/581
| * | libtracker-common: Fix compiler warnings in libunistring moduleCarlos Garnacho2023-03-021-11/+11
| | | | | | | | | | | | | | | | | | This was broken and untested for very long, so it accumulated some compiler warnings. This module is still on the hook and makes some tests fail, fix these warnings anyway.
| * | libtracker-common: Convert unicode parser to a GModuleCarlos Garnacho2023-03-024-10/+291
| | | | | | | | | | | | | | | | | | | | | | | | These are big and hairy dependencies, probably unwanted if anybody wishes dbus connections but not local ones. Making them a GModule means they are only loaded when strictly needed. Closes: https://gitlab.gnome.org/GNOME/tracker/-/issues/396
| * | libtracker-common: Move TrackerLanguage management to TrackerParserCarlos Garnacho2023-03-024-15/+8
| | | | | | | | | | | | | | | This is only created to give it to the parser, have it created from there and detach TrackerLanguage from the rest of the code.
| * | libtracker-common: Drop locale utilsCarlos Garnacho2023-03-026-129/+0
| | | | | | | | | | | | This somewhat pointless boilerplate, get rid of it.
| * | libtracker-sparql: Use setlocale() directly to query localeCarlos Garnacho2023-03-022-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Long long ago, this was an integration point since the Maemo platform (I thought I'd never write that in 2023) had some infrastructure to allow on-the-fly locale changes. This is long long gone, and nowadays it's just a setlocale() wrapper with a recursive lock that does nothing since all MT-unsafety of this function comes from the global environment. We can just setlocale() directly to query the locale details, with pretty much all the same guarantees.
| * | direct: Do not sanity check localeCarlos Garnacho2023-03-023-32/+0
| | | | | | | | | | | | | | | Even if unset/C, it's a locale change that we register and honor in consequence, it's not Tracker library's place to complain.
| * | build: Remove define leftoversCarlos Garnacho2023-03-021-4/+0
| | | | | | | | | | | | | | | The HAVE_LIBICU/LIBUNISTRING defines should not be needed for anything now.
| * | core: Move collation handling with other unicode codeCarlos Garnacho2023-03-025-178/+130
| | | | | | | | | | | | | | | Move these implementations together with the libicu/libunistring implementations.
| * | core: Drop glib-based collationCarlos Garnacho2023-03-021-52/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | This code pretty much boils down to g_utf8_collate(), and is in practice unused since there's always a libicu or libunistring implementation available. It would be nice to consolidate things into glib, but this deserves its own performance analysis with the other options.
| * | core: Move unicode treatment SPARQL function features to helpersCarlos Garnacho2023-03-024-325/+314
| | | | | | | | | | | | | | | Have the helpers defined together with the TrackerParser, so we don't drag details about the unicode library to other parts of the code.
| * | core: Move function out of ifdefCarlos Garnacho2023-03-021-25/+25
| |/ | | | | | | | | | | This function is only defined if the libicu-based text parser is enabled, but does not belong there. Move it out, and fix build when enabling libunistring for unicode management.
* | direct: Drop custom thread pool sorting ordersCarlos Garnacho2023-02-241-14/+0
| | | | | | | | | | | | | | | | These sort by task priority, but all inserted tasks get the same default priority. We can just rely on the default/implicit thread pool order, as that is what will happen anyways. Spotted during investigation of the previous commit.
* | bus: Plug GVariant leaksCarlos Garnacho2023-02-242-8/+10
| | | | | | | | | | | | | | | | There were a couple of GVariant leaks, in the handling of DBus replies and TrackerSparqlStatement parameter handling. Shuffle the variant floating reference ownership of parameters so it's "owned" by the hash table, and not picked by the first GVariantBuilder.
* | core: Plug a possible leak in TrackerGrammarParserCarlos Garnacho2023-02-241-0/+1
| | | | | | | | | | If a parsing error is raised, the array holding the state stack for errors is being leaked.
* | core: Plug leak in TrackerSparqlCarlos Garnacho2023-02-241-0/+1
| | | | | | | | | | Commit 38ec817c81 made TrackerSparql keep a reference to the literals array, but forgot to unref it.
* | core: Plug leak in tracker_triples virtual tableCarlos Garnacho2023-02-241-2/+0
| | | | | | | | | | The string was mistakenly doubly allocated when dealing with multi-valued properties.
* | libtracker-sparql: Plug leak in TrackerEndpointDBusCarlos Garnacho2023-02-241-0/+1
|/ | | | | The GVariants being extracted during iteration were being leaked.
* core: Bail out correctly on errorsCarlos Garnacho2023-02-141-1/+1
| | | | | We have 2 nested loops here, but we should break of them all. Avoids possibly continuing and/or rewriting the already set GError.
* libtracker-sparql: Fall back to updates parsing loading SPARQL from GResourceCarlos Garnacho2023-02-141-1/+16
| | | | | | This is a single API entrypoint that may create either select or update statements. Make it handle properly both by falling back. If the SPARQL was not parsed by either, an error is picked and raised.
* core: Propagate parsing errors directly on TrackerSparql creationCarlos Garnacho2023-02-147-46/+81
| | | | | | | | | | | We used to error out on parsing errors on first execution. Make this propagated early, so that it is possible to know at TrackerSparqlStatement creation time whether parsing was successful or not. This typically didn't matter since statements could only be used with select queries, and erroring out on first tracker_sparql_cursor_next() is alright. But now statements are used for both updates and selects, possibly from the same entrypoint, so it's better to error out early.
* core: Fix ontology updates on FTS propertiesCarlos Garnacho2023-01-271-0/+15
| | | | | | | | | As the last nco:phoneNumber FTS property removal shown, we do seem to be missing the ontology update of the FTS property (i.e. modifying or removing nrl:fulltextIndexed). Handle that, so that we are not left with the stale property value, possibly confusing things.
* libtracker-common: Add 'fts-integrity' debug flagCarlos Garnacho2023-01-233-0/+29
| | | | | | | | | | This debug flag forces a FTS integrity check after every set of FTS updates, and raises an error if the integrity check did fail. This is a more proactive (and expensive) approach to finding out FTS index corruptions. In order to make this helpful right away, toggle this flag on for our own test suite, so that CI may catch any remaining/popping issues.
* libtracker-sparql: Propagate corruption errors upCarlos Garnacho2023-01-234-19/+37
| | | | | | | | | | | | Right now the handling of those is somewhat inconsistent, we loudly warn, but simply return FALSE from our stmt_step() function without setting an error. Fortunately, the most common reason for those errors has been the soft corruption resulting from FTS index corruption, so continuing despite the error was alright. Propagate these error situations properly through a new TRACKER_SPARQL_ERROR_CORRUPT error code, so that callers can fail, rollback, or otherwise react upon.
* core: Check and repair FTS integrity during integrity checkCarlos Garnacho2023-01-235-0/+65
| | | | | | Extend the integrity check so it covers FTS index integrity in all graph databases. If FTS is still corrupt after rebuild, an error will be indirectly risen.
* core: Add TrackerDBManager::integrity-check signalCarlos Garnacho2023-01-232-13/+44
| | | | | | | | | We will want to handle integrity in a way that is dependent of database structure and other things handled by the upper layers, in fact we already do. Add a TrackerDBManager::integrity-check signal, that TrackerDataManager connects to, and move the basic database structure check there.