tracker r2844 - in trunk: . src/libtracker-data src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2844 - in trunk: . src/libtracker-data src/tracker-indexer
- Date: Tue, 27 Jan 2009 13:07:11 +0000 (UTC)
Author: carlosg
Date: Tue Jan 27 13:07:10 2009
New Revision: 2844
URL: http://svn.gnome.org/viewvc/tracker?rev=2844&view=rev
Log:
2009-01-27 Carlos Garnacho <carlos imendio com>
* src/libtracker-data/tracker-data-update.[ch]
(tracker_data_update_move_service): Make if return FALSE if the
operation failed.
* src/tracker-indexer/tracker-indexer.c (item_move): Handle move
operations that overwrite the dest file.
Modified:
trunk/ChangeLog
trunk/src/libtracker-data/tracker-data-update.c
trunk/src/libtracker-data/tracker-data-update.h
trunk/src/tracker-indexer/tracker-indexer.c
Modified: trunk/src/libtracker-data/tracker-data-update.c
==============================================================================
--- trunk/src/libtracker-data/tracker-data-update.c (original)
+++ trunk/src/libtracker-data/tracker-data-update.c Tue Jan 27 13:07:10 2009
@@ -268,7 +268,7 @@
NULL);
}
-void
+gboolean
tracker_data_update_move_service (TrackerService *service,
const gchar *from,
const gchar *to)
@@ -279,10 +279,11 @@
gchar *from_basename;
gchar *to_dirname;
gchar *to_basename;
+ gboolean retval = TRUE;
- g_return_if_fail (TRACKER_IS_SERVICE (service));
- g_return_if_fail (from != NULL);
- g_return_if_fail (to != NULL);
+ g_return_val_if_fail (TRACKER_IS_SERVICE (service), FALSE);
+ g_return_val_if_fail (from != NULL, FALSE);
+ g_return_val_if_fail (to != NULL, FALSE);
iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
TRACKER_DB_CONTENT_TYPE_METADATA);
@@ -295,27 +296,40 @@
&to_basename);
tracker_db_interface_execute_procedure (iface,
- NULL,
+ &error,
"MoveService",
to_dirname, to_basename,
from_dirname, from_basename,
NULL);
- if (strcmp (tracker_service_get_name (service), "Folders") == 0) {
- tracker_db_interface_execute_procedure (iface,
- &error,
- "MoveServiceChildren",
- from,
- to,
- from,
- from,
- NULL);
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ retval = FALSE;
+ } else {
+ if (strcmp (tracker_service_get_name (service), "Folders") == 0) {
+ tracker_db_interface_execute_procedure (iface,
+ &error,
+ "MoveServiceChildren",
+ from,
+ to,
+ from,
+ from,
+ NULL);
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+ }
}
g_free (to_dirname);
g_free (to_basename);
g_free (from_dirname);
g_free (from_basename);
+
+ return retval;
}
void
Modified: trunk/src/libtracker-data/tracker-data-update.h
==============================================================================
--- trunk/src/libtracker-data/tracker-data-update.h (original)
+++ trunk/src/libtracker-data/tracker-data-update.h Tue Jan 27 13:07:10 2009
@@ -48,7 +48,7 @@
guint32 service_id);
void tracker_data_update_delete_service_recursively (TrackerService *service,
const gchar *service_path);
-void tracker_data_update_move_service (TrackerService *service,
+gboolean tracker_data_update_move_service (TrackerService *service,
const gchar *from,
const gchar *to);
Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c (original)
+++ trunk/src/tracker-indexer/tracker-indexer.c Tue Jan 27 13:07:10 2009
@@ -205,6 +205,12 @@
TrackerIndexerState state);
static void state_check (TrackerIndexer *indexer);
+static void item_remove (TrackerIndexer *indexer,
+ PathInfo *info,
+ const gchar *dirname,
+ const gchar *basename);
+
+
static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (TrackerIndexer, tracker_indexer, G_TYPE_OBJECT)
@@ -1586,9 +1592,38 @@
return;
}
- /* Get mime type and move thumbnail from thumbnailerd */
+ /* Get mime type in order to move thumbnail from thumbnailerd */
old_metadata = tracker_data_query_metadata (service, service_id, TRUE);
+ if (!tracker_data_update_move_service (service, source_path, path)) {
+ gchar *dest_dirname, *dest_basename;
+
+ /* Move operation failed, which means the dest path
+ * corresponded to an indexed file, remove any info
+ * related to it.
+ */
+
+ g_message ("Destination file '%s' already existed in database, removing", path);
+
+ tracker_file_get_path_and_name (path, &dest_dirname, &dest_basename);
+ item_remove (indexer, info, dest_dirname, dest_basename);
+
+ g_free (dest_dirname);
+ g_free (dest_basename);
+
+ if (!tracker_data_update_move_service (service, source_path, path)) {
+ /* It failed again, no point in trying anymore */
+ g_free (path);
+ g_free (source_path);
+
+ if (old_metadata) {
+ tracker_data_metadata_free (old_metadata);
+ }
+
+ return;
+ }
+ }
+
if (old_metadata) {
const gchar *mime_type;
@@ -1606,8 +1641,6 @@
path);
}
- tracker_data_update_move_service (service, source_path, path);
-
if (tracker_hal_path_is_on_removable_device (indexer->private->hal,
source_path,
&mount_point,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]