Commit d212d0d6 authored by Sam Thursfield's avatar Sam Thursfield Committed by Debarshi Ray

Switch to private instances of the Tracker 2.x daemons

GNOME 3.38 is switching to Tracker 3.x by default [1]. However, Photos
is not ready to switch this cycle.

It's desirable to avoid having two sets of Tracker daemons indexing
the same content as much as possible. One option is to start private
instances of the Tracker 2.x daemons tied to the lifetime of the GNOME
Photos application. Distributions can disable Tracker 2.x by default,
and it will only be activated when needed by Photos.

This also allows the Photos Flatpak to run Tracker 2.x daemons inside
the sandbox, ensuring it works on systems which don't have Tracker 2.x
available.

Based on code written by Yi-Soo An.

[1] Initiatives#17

!146
parent f1f5639f
Pipeline #215939 passed with stage
in 16 minutes and 40 seconds
......@@ -45,6 +45,35 @@ configure_file(
install_dir: dbus_services_dir,
)
tracker_domain_conf = configuration_data()
tracker_domain_conf.set('libexecdir', photos_libexecdir)
domain_ontology_rule = photos_namespace + '.rule'
configure_file(
input: domain_ontology_rule + '.in',
output: domain_ontology_rule,
configuration: tracker_domain_conf,
install: true,
install_dir: join_paths(photos_datadir, 'tracker', 'domain-ontologies'),
)
tracker_domain_services = [
'Tracker1',
'Tracker1.Miner.Extract',
'Tracker1.Miner.Files'
]
foreach service: tracker_domain_services
configure_file(
input: '@0@.@1@.service.in'.format(photos_namespace, service),
output: '@0@.@1@.service'.format(photos_namespace, service),
configuration: tracker_domain_conf,
install: true,
install_dir: dbus_services_dir,
)
endforeach
install_data(
photos_namespace + '.search-provider.ini',
install_dir: join_paths(photos_datadir, 'gnome-shell', 'search-providers'),
......
[D-BUS Service]
Name=org.gnome.Photos.Tracker1.Miner.Extract
Exec=@libexecdir@/tracker-extract --domain-ontology org.gnome.Photos
# Miner details needed for tracker-control
Path=/org/freedesktop/Tracker1/Miner/Extract
NameSuffix=Miner.Extract
DisplayName=Extractor
[D-BUS Service]
Name=org.gnome.Photos.Tracker1.Miner.Files
Exec=@libexecdir@/tracker-miner-fs --initial-sleep=0 --domain-ontology org.gnome.Photos
# Miner details needed for tracker-control
Path=/org/freedesktop/Tracker1/Miner/Files
NameSuffix=Miner.Files
DisplayName=File System
[D-BUS Service]
Name=org.gnome.Photos.Tracker1
Exec=@libexecdir@/tracker-store --domain-ontology org.gnome.Photos
[DomainOntology]
# All locations accept
# 1) Paths relative from a variable, the variables
# may be: HOME, XDG_CACHE_HOME, XDG_DATA_HOME, XDG_RUNTIME_DIR,
# XDG_DESKTOP_DIR, XDG_DOCUMENTS_DIR, XDG_DOWNLOAD_DIR,
# XDG_MUSIC_DIR, XDG_PICTURES_DIR, XDG_PUBLICSHARE_DIR,
# XDG_VIDEOS_DIR.
#
# eg. $XDG_CACHE_HOME/...
#
# 2) URIs
#
# eg. file:///var/...
#
# Location for the Tracker database (not optional)
CacheLocation=$XDG_CACHE_HOME/tracker
# Location for the data journal, used in data recovery
# situations (optional)
JournalLocation=$XDG_DATA_HOME/tracker/data
# Name of the ontology to use, must be one located in
# $(sharedir)/tracker/ontologies
OntologyName=nepomuk
# DBus name for the owner (not optional). Tracker will use
# the domain as the prefix of the DBus name for all the
# services related to this domain ontology.
#
# eg. org.gnome.Photos
Domain=org.gnome.Photos
# Miners that the domain ontology will require. This is
# purely a hint (mainly for libtracker-control), and not
# any sort of white list. Anything else knowing about this
# domain ontology may still perform updates, miners and
# non-miners.
Miners=Miner.Files;Miner.Extract
......@@ -251,7 +251,7 @@
{
"name": "tracker",
"buildsystem": "meson",
"cleanup": [ "/bin", "/etc", "/lib/girepository-1.0", "/libexec", "/share/dbus-1", "/share/gir-1.0" ],
"cleanup": [ "/bin", "/etc", "/lib/girepository-1.0", "/share/dbus-1", "/share/gir-1.0" ],
"config-opts": [ "-Dbash_completion=no", "-Ddocs=false", "-Dsystemd_user_services=no" ],
"sources": [
{
......@@ -276,18 +276,13 @@
"name": "tracker-miners",
"buildsystem": "meson",
"cleanup": [ "/etc",
"/lib",
"/libexec",
"/share/dbus-1/services/org.freedesktop.Tracker1.Miner.Extract.service",
"/share/dbus-1/services/org.freedesktop.Tracker1.Writeback.service",
"/share/tracker/miners/org.freedesktop.Tracker1.Miner.Applications.service",
"/share/tracker/miners/org.freedesktop.Tracker1.Miner.Extract.service",
"/share/tracker/miners/org.freedesktop.Tracker1.Miner.RSS.service",
"/share/tracker-miners",
"/share/glib-2.0/schemas/org.freedesktop.Tracker.Extract.gschema.xml",
"/share/glib-2.0/schemas/org.freedesktop.Tracker.Writeback.gschema.xml" ],
"config-opts": [ "-Dextract=false",
"-Dgeneric_media_extractor=none",
"config-opts": [ "-Dextract=true",
"-Dminer_fs=true",
"-Dminer_rss=false",
"-Dsystemd_user_services=no",
......
......@@ -211,4 +211,5 @@ run_target(script_name, command: [find_program(script_name + '.sh'), source_root
meson.add_install_script(
'meson_post_install.py',
photos_datadir,
dbus_services_dir,
)
......@@ -28,3 +28,17 @@ if not destdir:
schemadir = os.path.join(datadir, 'glib-2.0', 'schemas')
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])
dbusservicesdir = sys.argv[2]
trackerdir = os.path.join(datadir, 'tracker', 'miners')
miners = ["org.gnome.Photos.Tracker1.Miner.Extract.service", "org.gnome.Photos.Tracker1.Miner.Files.service"]
os.makedirs(trackerdir, exist_ok=True)
for miner in miners:
dst = os.path.join(trackerdir, miner)
src = os.path.join(dbusservicesdir, miner)
try:
os.symlink(src, dst)
except FileExistsError:
pass
......@@ -127,6 +127,7 @@ struct _PhotosApplication
PhotosSearchProvider *search_provider;
PhotosSelectionController *sel_cntrlr;
PhotosThumbnailFactory *factory;
TrackerMinerManager *miner_manager;
TrackerExtractPriority *extract_priority;
gboolean empty_results;
gboolean main_window_deleted;
......@@ -173,6 +174,7 @@ static const gchar *DESKTOP_KEY_PICTURE_OPTIONS = "picture-options";
static const gchar *DESKTOP_KEY_COLOR_SHADING_TYPE = "color-shading-type";
static const gchar *DESKTOP_KEY_PRIMARY_COLOR = "primary-color";
static const gchar *DESKTOP_KEY_SECONDARY_COLOR = "secondary-color";
static const gchar *MINER_FILES = "org.gnome.Photos.Tracker1.Miner.Files";
typedef struct _PhotosApplicationCreateData PhotosApplicationCreateData;
typedef struct _PhotosApplicationImportData PhotosApplicationImportData;
......@@ -195,7 +197,6 @@ struct _PhotosApplicationImportData
GFile *import_sub_dir;
GList *files;
PhotosBaseItem *collection;
TrackerMinerManager *manager;
gchar *collection_urn;
gint64 ctime_latest;
};
......@@ -248,7 +249,6 @@ photos_application_create_data_free (PhotosApplicationCreateData *data)
static PhotosApplicationImportData *
photos_application_import_data_new (PhotosApplication *application,
TrackerMinerManager *manager,
GList *files,
gint64 ctime_latest)
{
......@@ -257,7 +257,6 @@ photos_application_import_data_new (PhotosApplication *application,
data = g_slice_new0 (PhotosApplicationImportData);
g_application_hold (G_APPLICATION (application));
data->application = application;
data->manager = g_object_ref (manager);
data->files = g_list_copy_deep (files, (GCopyFunc) g_object_ref, NULL);
data->ctime_latest = ctime_latest;
return data;
......@@ -278,7 +277,6 @@ photos_application_import_data_free (PhotosApplicationImportData *data)
g_clear_object (&data->destination);
g_clear_object (&data->import_sub_dir);
g_list_free_full (data->files, g_object_unref);
g_clear_object (&data->manager);
g_free (data->collection_urn);
g_slice_free (PhotosApplicationImportData, data);
}
......@@ -830,7 +828,7 @@ photos_application_create_window (PhotosApplication *self)
g_application_hold (G_APPLICATION (self));
tracker_extract_priority_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.Tracker1.Miner.Extract",
"org.gnome.Photos.Tracker1.Miner.Extract",
"/org/freedesktop/Tracker1/Extract/Priority",
self->create_window_cancellable,
photos_application_tracker_extract_priority,
......@@ -1323,7 +1321,6 @@ photos_application_import_file_copy (GObject *source_object, GAsyncResult *res,
PhotosApplication *self = data->application;
g_autoptr (GFile) destination = NULL;
GFile *source = G_FILE (source_object);
TrackerMinerManager *manager = data->manager;
{
g_autoptr (GError) error = NULL;
......@@ -1364,7 +1361,7 @@ photos_application_import_file_copy (GObject *source_object, GAsyncResult *res,
g_application_hold (G_APPLICATION (self));
g_application_mark_busy (G_APPLICATION (self));
tracker_miner_manager_index_file_for_process_async (manager,
tracker_miner_manager_index_file_for_process_async (self->miner_manager,
destination,
NULL,
photos_application_import_index_file,
......@@ -1519,7 +1516,6 @@ photos_application_import (PhotosApplication *self)
GtkWidget *dialog;
g_autoptr (PhotosApplicationImportData) data = NULL;
PhotosSource *source;
TrackerMinerManager *manager = NULL; /* TODO: use g_autoptr */
gint64 ctime_latest = -1;
source = PHOTOS_SOURCE (photos_base_manager_get_active_object (self->state->src_mngr));
......@@ -1533,17 +1529,11 @@ photos_application_import (PhotosApplication *self)
selection = photos_selection_controller_get_selection (self->sel_cntrlr);
g_return_if_fail (selection != NULL);
{
g_autoptr (GError) error = NULL;
manager = tracker_miner_manager_new_full (FALSE, &error);
if (error != NULL)
{
g_warning ("Unable to create a TrackerMinerManager, importing from attached devices won't work: %s",
error->message);
goto out;
}
}
if (self->miner_manager == NULL)
{
g_warning ("No TrackerMinerManager, importing from attached devices won't work");
goto out;
}
for (l = selection; l != NULL; l = l->next)
{
......@@ -1572,14 +1562,13 @@ photos_application_import (PhotosApplication *self)
dialog = photos_import_dialog_new (GTK_WINDOW (self->main_window), ctime_latest);
gtk_widget_show_all (dialog);
data = photos_application_import_data_new (self, manager, files, ctime_latest);
data = photos_application_import_data_new (self, files, ctime_latest);
g_signal_connect (dialog,
"response",
G_CALLBACK (photos_application_import_response),
g_steal_pointer (&data));
out:
g_clear_object (&manager);
g_list_free_full (files, g_object_unref);
}
......@@ -2245,7 +2234,35 @@ photos_application_share_current (PhotosApplication *self)
static void
photos_application_start_miners (PhotosApplication *self)
{
photos_application_create_online_miners (self);
{
g_autoptr (GError) error = NULL;
self->miner_manager = tracker_miner_manager_new_full (TRUE, &error);
if (error != NULL)
g_warning ("Unable to create a TrackerMinerManager: %s", error->message);
}
if (self->miner_manager != NULL)
{
GSList *available = NULL;
GSList *miner_files = NULL;
available = tracker_miner_manager_get_available (self->miner_manager);
miner_files = g_slist_find_custom (available, MINER_FILES, (GCompareFunc) strcmp);
if (miner_files == NULL)
{
g_warning ("Unable to find miner %s", MINER_FILES);
}
else
{
if (!tracker_miner_manager_is_active (self->miner_manager, MINER_FILES))
g_warning ("Unable to activate miner %s", MINER_FILES);
}
g_slist_free_full (available, g_free);
}
photos_application_create_online_miners (self);
}
......@@ -3003,6 +3020,7 @@ photos_application_dispose (GObject *object)
g_clear_object (&self->sel_cntrlr);
g_clear_object (&self->factory);
g_clear_object (&self->extract_priority);
g_clear_object (&self->miner_manager);
if (self->state != NULL)
{
......
......@@ -56,7 +56,7 @@ enum
REMOTE_MINER_TIMEOUT = 10 /* s */
};
static const gchar *MINER_FILES = "org.freedesktop.Tracker1.Miner.Files";
static const gchar *MINER_FILES = "org.gnome.Photos.Tracker1.Miner.Files";
static void
......@@ -242,7 +242,7 @@ photos_indexing_notification_init (PhotosIndexingNotification *self)
{
g_autoptr (GError) error = NULL;
self->manager = tracker_miner_manager_new_full (FALSE, &error);
self->manager = tracker_miner_manager_new_full (TRUE, &error);
if (error != NULL)
{
g_warning ("Unable to create a TrackerMinerManager, indexing progress notification won't work: %s",
......
......@@ -434,7 +434,7 @@ photos_tracker_change_monitor_initable_init (GInitable *initable, GCancellable *
self->resource_service = tracker_resources_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.Tracker1",
"org.gnome.Photos.Tracker1",
"/org/freedesktop/Tracker1/Resources",
cancellable,
error);
......
......@@ -424,7 +424,7 @@ photos_tracker_import_controller_init (PhotosTrackerImportController *self)
{
g_autoptr (GError) error = NULL;
self->manager = tracker_miner_manager_new_full (FALSE, &error);
self->manager = tracker_miner_manager_new_full (TRUE, &error);
if (error != NULL)
g_warning ("Unable to create a TrackerMinerManager, indexing attached devices won't work: %s", error->message);
}
......
......@@ -290,6 +290,8 @@ photos_tracker_queue_initable_init (GInitable *initable, GCancellable *cancellab
g_assert_no_error (self->initialization_error);
tracker_sparql_connection_set_domain ("org.gnome.Photos");
self->connection = tracker_sparql_connection_get (cancellable, &self->initialization_error);
if (G_UNLIKELY (self->initialization_error != NULL))
goto out;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment