[tracker-miners/sam/index-location: 5/8] Remove "reindex MIME types" action
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/sam/index-location: 5/8] Remove "reindex MIME types" action
- Date: Sat, 11 Jul 2020 18:35:37 +0000 (UTC)
commit 881c976fa8c3f6cb3f8e59063cb760edef12c5af
Author: Sam Thursfield <sam afuera me uk>
Date: Fri Mar 6 00:55:35 2020 +0100
Remove "reindex MIME types" action
I think the use case for this was updating the index after out-of-tree
Tracker extract modules are installed. We no longer support out-of-tree
extract modules. Users will still be able to run `tracker index` to
update specific files in the index.
docs/manpages/tracker-index.1.txt | 6 --
src/miners/fs/tracker-miner-files-index.c | 137 +-----------------------------
src/tracker/tracker-index.c | 44 +---------
src/tracker/tracker-miner-manager.c | 61 -------------
src/tracker/tracker-miner-manager.h | 3 -
5 files changed, 2 insertions(+), 249 deletions(-)
---
diff --git a/docs/manpages/tracker-index.1.txt b/docs/manpages/tracker-index.1.txt
index 039fc5cee..c2121242e 100644
--- a/docs/manpages/tracker-index.1.txt
+++ b/docs/manpages/tracker-index.1.txt
@@ -9,7 +9,6 @@ content
== SYNOPSIS
....
-tracker index --reindex-mime-type <mime1> [[-m [mime2]] ...]
tracker index --file <file1> [[file2] ...]
tracker index --import <file1> [[file2] ...]
tracker index --backup <file> | --restore <file>
@@ -34,11 +33,6 @@ Finally, there is an import feature which makes testing or applying a
== OPTIONS
-*-m, --reindex-mime-type=<__mime1__> [[-m [_mime2_]] ...]*::
- Re-index files which match the _mime_ type supplied. This is usually
- used when installing new extractors which support _mime_ types
- previously unsupported. This forces Tracker to re-index those files.
- You can use *--reindex-mime-type* more than once per _mime_ type.
*-f, --index=<__file1__> [[_file2_] ...]*::
(Re)index a file matching the _file_ name(s) supplied.
*-b, --backup=<__file__>*::
diff --git a/src/miners/fs/tracker-miner-files-index.c b/src/miners/fs/tracker-miner-files-index.c
index f7636734b..82a2c0473 100644
--- a/src/miners/fs/tracker-miner-files-index.c
+++ b/src/miners/fs/tracker-miner-files-index.c
@@ -30,9 +30,6 @@
static const gchar introspection_xml[] =
"<node>"
" <interface name='org.freedesktop.Tracker3.Miner.Files.Index'>"
- " <method name='ReindexMimeTypes'>"
- " <arg type='as' name='mime_types' direction='in' />"
- " </method>"
" <method name='IndexFile'>"
" <arg type='s' name='file_uri' direction='in' />"
" </method>"
@@ -202,136 +199,6 @@ index_finalize (GObject *object)
g_object_unref (priv->files_miner);
}
-static MimeTypesData *
-mime_types_data_new (TrackerDBusRequest *request,
- GDBusMethodInvocation *invocation,
- TrackerSparqlConnection *connection,
- TrackerMinerFiles *miner_files)
-{
- MimeTypesData *mtd;
-
- mtd = g_slice_new0 (MimeTypesData);
-
- mtd->miner_files = g_object_ref (miner_files);
- mtd->request = request;
- mtd->invocation = invocation;
- mtd->connection = g_object_ref (connection);
-
- return mtd;
-}
-
-static void
-mime_types_data_destroy (gpointer data)
-{
- MimeTypesData *mtd;
-
- mtd = data;
-
- g_object_unref (mtd->miner_files);
- g_object_unref (mtd->connection);
-
- g_slice_free (MimeTypesData, mtd);
-}
-
-static void
-mime_types_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- MimeTypesData *mtd = user_data;
- TrackerSparqlCursor *cursor;
- GError *error = NULL;
-
- cursor = tracker_sparql_connection_query_finish (TRACKER_SPARQL_CONNECTION (object),
- result,
- &error);
-
- if (cursor) {
- tracker_dbus_request_comment (mtd->request,
- "Found files that will need reindexing");
-
- while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
- GFile *file;
- const gchar *url;
-
- url = tracker_sparql_cursor_get_string (cursor, 0, NULL);
- file = g_file_new_for_uri (url);
- tracker_miner_fs_check_file (TRACKER_MINER_FS (mtd->miner_files),
- file, G_PRIORITY_HIGH, FALSE);
- g_object_unref (file);
- }
-
- tracker_dbus_request_end (mtd->request, NULL);
- g_dbus_method_invocation_return_value (mtd->invocation, NULL);
- } else {
- tracker_dbus_request_end (mtd->request, error);
- g_dbus_method_invocation_return_gerror (mtd->invocation, error);
- }
-
- mime_types_data_destroy (user_data);
-}
-
-static void
-tracker_miner_files_index_reindex_mime_types (TrackerMinerFilesIndex *miner,
- GDBusMethodInvocation *invocation,
- GVariant *parameters)
-{
- TrackerMinerFilesIndexPrivate *priv;
- GString *query;
- TrackerSparqlConnection *connection;
- TrackerDBusRequest *request;
- gint len, i;
- GStrv mime_types = NULL;
-
- priv = TRACKER_MINER_FILES_INDEX_GET_PRIVATE (miner);
-
- g_variant_get (parameters, "(^a&s)", &mime_types);
-
- len = mime_types ? g_strv_length (mime_types) : 0;
-
- tracker_gdbus_async_return_if_fail (len > 0, invocation);
-
- request = tracker_g_dbus_request_begin (invocation, "%s(%d mime types)",
- __FUNCTION__,
- len);
-
- connection = tracker_miner_get_connection (TRACKER_MINER (priv->files_miner));
-
- tracker_dbus_request_comment (request,
- "Attempting to reindex the following mime types:");
-
- query = g_string_new ("SELECT ?url "
- "WHERE {"
- " ?resource nie:url ?url ;"
- " nie:interpretedAs/nie:mimeType ?mime ."
- " FILTER(");
-
- for (i = 0; i < len; i++) {
- tracker_dbus_request_comment (request, " %s", mime_types[i]);
- g_string_append_printf (query, "?mime = '%s'", mime_types[i]);
-
- if (i < len - 1) {
- g_string_append (query, " || ");
- }
- }
-
- g_string_append (query, ") }");
-
- /* FIXME: save last call id */
- tracker_sparql_connection_query_async (connection,
- query->str,
- NULL,
- mime_types_cb,
- mime_types_data_new (request,
- invocation,
- connection,
- priv->files_miner));
-
- g_string_free (query, TRUE);
- g_object_unref (connection);
- g_free (mime_types);
-}
-
static void
handle_method_call_index_file (TrackerMinerFilesIndex *miner,
GDBusMethodInvocation *invocation,
@@ -461,9 +328,7 @@ handle_method_call (GDBusConnection *connection,
tracker_gdbus_async_return_if_fail (miner != NULL, invocation);
tracker_gdbus_async_return_if_fail (TRACKER_IS_MINER_FILES_INDEX (miner), invocation);
- if (g_strcmp0 (method_name, "ReindexMimeTypes") == 0) {
- tracker_miner_files_index_reindex_mime_types (miner, invocation, parameters);
- } else if (g_strcmp0 (method_name, "IndexFile") == 0) {
+ if (g_strcmp0 (method_name, "IndexFile") == 0) {
handle_method_call_index_file (miner, invocation, parameters, FALSE);
} else if (g_strcmp0 (method_name, "IndexFileForProcess") == 0) {
handle_method_call_index_file (miner, invocation, parameters, TRUE);
diff --git a/src/tracker/tracker-index.c b/src/tracker/tracker-index.c
index 8db4ccce8..b8b3d2f1f 100644
--- a/src/tracker/tracker-index.c
+++ b/src/tracker/tracker-index.c
@@ -36,7 +36,6 @@
#include "tracker-dbus.h"
#include "tracker-miner-manager.h"
-static gchar **reindex_mime_types;
static gboolean index_file;
static gboolean backup;
static gboolean restore;
@@ -48,13 +47,9 @@ static gchar **filenames;
(index_file || \
backup || \
restore || \
- import) || \
- reindex_mime_types)
+ import))
static GOptionEntry entries[] = {
- { "reindex-mime-type", 'm', 0, G_OPTION_ARG_STRING_ARRAY, &reindex_mime_types,
- N_("Tell miners to reindex files which match the mime type supplied (for new extractors), use -m
MIME1 -m MIME2"),
- N_("MIME") },
{ "file", 'f', 0, G_OPTION_ARG_NONE, &index_file,
N_("Tell miners to (re)index a given file"),
N_("FILE") },
@@ -110,37 +105,6 @@ get_uri_from_arg (const gchar *arg)
return uri;
}
-static int
-reindex_mimes (void)
-{
- GError *error = NULL;
- TrackerMinerManager *manager;
-
- /* Auto-start the miners here if we need to */
- manager = tracker_miner_manager_new_full (TRUE, &error);
- if (!manager) {
- g_printerr (_("Could not reindex mimetypes, manager could not be created, %s"),
- error ? error->message : _("No error given"));
- g_printerr ("\n");
- g_clear_error (&error);
- return EXIT_FAILURE;
- }
-
- tracker_miner_manager_reindex_by_mimetype (manager, (GStrv) reindex_mime_types, &error);
- if (error) {
- g_printerr ("%s: %s\n",
- _("Could not reindex mimetypes"),
- error->message);
- g_error_free (error);
- return EXIT_FAILURE;
- }
-
- g_print ("%s\n", _("Reindexing mime types was successful"));
- g_object_unref (manager);
-
- return EXIT_SUCCESS;
-}
-
static gint
index_or_reindex_file (void)
{
@@ -353,10 +317,6 @@ restore_index (void)
static int
index_run (void)
{
- if (reindex_mime_types) {
- return reindex_mimes ();
- }
-
if (index_file) {
return index_or_reindex_file ();
}
@@ -453,8 +413,6 @@ main (int argc, const char **argv)
failed = _("Missing one or more files which are required");
} else if ((backup || restore) && (filenames && g_strv_length (filenames) > 1)) {
failed = _("Only one file can be used with --backup and --restore");
- } else if (actions > 0 && (reindex_mime_types && g_strv_length (reindex_mime_types) > 0)) {
- failed = _("Actions (--backup, --restore, --index-file and --import) can not be used with
--reindex-mime-type");
} else {
failed = NULL;
}
diff --git a/src/tracker/tracker-miner-manager.c b/src/tracker/tracker-miner-manager.c
index 3131692f5..b021492b4 100644
--- a/src/tracker/tracker-miner-manager.c
+++ b/src/tracker/tracker-miner-manager.c
@@ -1406,67 +1406,6 @@ tracker_miner_manager_error_quark (void)
return error_quark;
}
-/**
- * tracker_miner_manager_reindex_by_mimetype:
- * @manager: a #TrackerMinerManager
- * @mimetypes: (in): an array of mimetypes (E.G. "text/plain"). All items
- * with a mimetype in that list will be reindexed.
- * @error: (out callee-allocates) (transfer full) (allow-none): return location for errors
- *
- * Tells the filesystem miner to reindex any file with a mimetype in
- * the @mimetypes list.
- *
- * On failure @error will be set.
- *
- * Returns: %TRUE on success, otherwise %FALSE.
- *
- * Since: 0.10
- **/
-gboolean
-tracker_miner_manager_reindex_by_mimetype (TrackerMinerManager *manager,
- const GStrv mimetypes,
- GError **error)
-{
- TrackerMinerManagerPrivate *priv;
- GVariant *v;
- GError *new_error = NULL;
-
- g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
- g_return_val_if_fail (mimetypes != NULL, FALSE);
-
- if (!tracker_miner_manager_is_active (manager,
- "org.freedesktop.Tracker3.Miner.Files")) {
- g_set_error_literal (error,
- TRACKER_MINER_MANAGER_ERROR,
- TRACKER_MINER_MANAGER_ERROR_NOT_AVAILABLE,
- "Filesystem miner is not active");
- return FALSE;
- }
-
- priv = tracker_miner_manager_get_instance_private (manager);
-
- v = g_dbus_connection_call_sync (priv->connection,
- "org.freedesktop.Tracker3.Miner.Files",
- "/org/freedesktop/Tracker3/Miner/Files/Index",
- "org.freedesktop.Tracker3.Miner.Files.Index",
- "ReindexMimeTypes",
- g_variant_new ("(^as)", mimetypes),
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &new_error);
-
- if (new_error) {
- g_propagate_error (error, new_error);
- return FALSE;
- }
-
- g_variant_unref (v);
-
- return FALSE;
-}
-
static gboolean
miner_manager_index_file_sync (TrackerMinerManager *manager,
const gchar *method_name,
diff --git a/src/tracker/tracker-miner-manager.h b/src/tracker/tracker-miner-manager.h
index d0927d21a..de77b48e0 100644
--- a/src/tracker/tracker-miner-manager.h
+++ b/src/tracker/tracker-miner-manager.h
@@ -128,9 +128,6 @@ const gchar * tracker_miner_manager_get_display_name (TrackerMinerManag
const gchar * tracker_miner_manager_get_description (TrackerMinerManager *manager,
const gchar *miner);
-gboolean tracker_miner_manager_reindex_by_mimetype (TrackerMinerManager *manager,
- const GStrv mimetypes,
- GError **error);
gboolean tracker_miner_manager_index_file (TrackerMinerManager *manager,
GFile *file,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]