[tracker/index-mount-points: 3/4] libtracker-miner: Cleaned up tracker_miner_fs_mount_add() function
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/index-mount-points: 3/4] libtracker-miner: Cleaned up tracker_miner_fs_mount_add() function
- Date: Thu, 31 Jan 2013 18:39:04 +0000 (UTC)
commit 360c0001d636076ff28f3048846b639708019286
Author: Martyn Russell <martyn lanedo com>
Date: Thu Jan 31 17:58:36 2013 +0000
libtracker-miner: Cleaned up tracker_miner_fs_mount_add() function
- Fixed memory leaks
- Used const types for const returns
- Avoided duplicate messaging
- Added checks for valid UUID returns
- Avoided freeing const char*
src/libtracker-miner/tracker-miner-fs.c | 29 +++++++++++++----------------
src/libtracker-miner/tracker-miner-fs.h | 4 ++--
2 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 9d79338..b2de3e5 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2906,9 +2906,6 @@ set_up_mount_point_cb (GObject *source,
g_critical ("Could not set mount point in database '%s', %s",
device_urn,
error->message);
- g_critical ("Could not set mount point in database '%s', %s",
- device_urn,
- error->message);
g_error_free (error);
}
@@ -2923,23 +2920,23 @@ set_up_mount_point_cb (GObject *source,
* Tells the filesystem miner to inspect a mount. It ignores the values
* of the index-removable-devices and index-optical-discs gsettings keys.
*
- * Since: 0.14
+ * Since: 0.16
**/
void
tracker_miner_fs_mount_add (TrackerMinerFS *fs,
GMount *mount)
{
GFile *mount_point;
- gchar *uri;
+ gchar *mount_uri;
GString *queries;
TrackerStorage *storage;
gchar *iri;
- gchar *uuid;
+ const gchar *uuid;
gchar *urn;
TrackerStorageType type;
mount_point = g_mount_get_root (mount);
- uri = g_file_get_uri (mount_point);
+ mount_uri = g_file_get_uri (mount_point);
queries = g_string_new (NULL);
@@ -2950,14 +2947,12 @@ tracker_miner_fs_mount_add (TrackerMinerFS *fs,
if (iri) {
/* if mount point exists in the store, nothing else to do */
- g_message ("Mount point '%s' already exists in store: '%s'", uri, iri);
-
+ g_message ("Mount point '%s' already exists in store: '%s'", mount_uri, iri);
g_free (iri);
} else {
/* If it doesn't exist, we need to create it */
- g_message ("Mount point '%s' does not exist in store, need to create it",
- uri);
/* Create a nfo:Folder for the mount point */
+ g_message ("Mount point '%s' does not exist in store, need to create it", mount_uri);
g_string_append_printf (queries,
"INSERT SILENT INTO <" TRACKER_MINER_FS_GRAPH_URN "> {"
" _:file a nfo:FileDataObject, nie:InformationElement, nfo:Folder ; "
@@ -2966,13 +2961,15 @@ tracker_miner_fs_mount_add (TrackerMinerFS *fs,
" nie:mimeType \"inode/directory\" ; "
" nfo:fileLastModified \"1981-06-05T02:20:00Z\" . "
"}",
- uri);
+ mount_uri);
}
uuid = tracker_storage_get_uuid_for_file (storage, mount_point);
+ g_return_if_fail (uuid != NULL);
+
+ /* Freed in set_up_mount_point_cb() */
urn = g_strconcat (TRACKER_DATASOURCE_URN_PREFIX, uuid, NULL);
type = tracker_storage_get_type_for_uuid (storage, uuid);
- g_free (uuid);
g_string_append_printf (queries,
"DELETE { <%s> a rdfs:Resource } "
@@ -2989,15 +2986,15 @@ tracker_miner_fs_mount_add (TrackerMinerFS *fs,
urn,
TRACKER_STORAGE_TYPE_IS_REMOVABLE (type) ? "true" : "false",
TRACKER_STORAGE_TYPE_IS_OPTICAL (type) ? "true" : "false",
- uri);
- g_free (uri);
+ mount_uri);
+ g_free (mount_uri);
tracker_sparql_connection_update_async (tracker_miner_get_connection (TRACKER_MINER (fs)),
queries->str,
G_PRIORITY_HIGH,
NULL,
set_up_mount_point_cb,
- g_strdup (urn));
+ urn);
g_string_free (queries, TRUE);
diff --git a/src/libtracker-miner/tracker-miner-fs.h b/src/libtracker-miner/tracker-miner-fs.h
index 6c20abc..1e9456c 100644
--- a/src/libtracker-miner/tracker-miner-fs.h
+++ b/src/libtracker-miner/tracker-miner-fs.h
@@ -101,8 +101,8 @@ gboolean tracker_miner_fs_directory_remove (TrackerMinerFS *fs,
GFile *file);
gboolean tracker_miner_fs_directory_remove_full (TrackerMinerFS *fs,
GFile *file);
-void tracker_miner_fs_mount_add (TrackerMinerFS *fs,
- GMount *mount);
+void tracker_miner_fs_mount_add (TrackerMinerFS *fs,
+ GMount *mount);
void tracker_miner_fs_check_file_with_priority (TrackerMinerFS *fs,
GFile *file,
gint priority,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]