[tracker-miners/wip/carlosg/shuffle-libtracker-miner: 56/116] libtracker-miner: Emit ::file-updated on file extension changes
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/shuffle-libtracker-miner: 56/116] libtracker-miner: Emit ::file-updated on file extension changes
- Date: Thu, 12 Dec 2019 10:25:36 +0000 (UTC)
commit 47c8391a064ab77dd3737646877a141d24579a07
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jun 22 23:56:57 2018 +0200
libtracker-miner: Emit ::file-updated on file extension changes
We have no access to past/current GFileInfos, so detect changes in
file extensions to handle the cases where a change of filename
results in the file having a different mimetype.
In these cases, ::file-updated should be emitted, so it gets the
right rdf:types as per its new mimetype.
src/libtracker-miner/tracker-file-notifier.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 780a94004..d90a73325 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -1322,6 +1322,28 @@ monitor_item_deleted_cb (TrackerMonitor *monitor,
g_object_unref (canonical);
}
+static gboolean
+extension_changed (GFile *file1,
+ GFile *file2)
+{
+ gchar *basename1, *basename2;
+ const gchar *ext1, *ext2;
+ gboolean changed;
+
+ basename1 = g_file_get_basename (file1);
+ basename2 = g_file_get_basename (file2);
+
+ ext1 = strrchr (basename1, '.');
+ ext2 = strrchr (basename2, '.');
+
+ changed = g_strcmp0 (ext1, ext2) != 0;
+
+ g_free (basename1);
+ g_free (basename2);
+
+ return changed;
+}
+
static void
monitor_item_moved_cb (TrackerMonitor *monitor,
GFile *file,
@@ -1445,6 +1467,9 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
}
g_signal_emit (notifier, signals[FILE_MOVED], 0, file, other_file);
+
+ if (extension_changed (file, other_file))
+ g_signal_emit (notifier, signals[FILE_UPDATED], 0, other_file, FALSE);
}
tracker_file_system_forget_files (priv->file_system, file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]