Author: post
Date: 2010-04-03 02:26:02 +0200 (Sat, 03 Apr 2010)
New Revision: 3322

Modified:
   trunk/src/rs-actions.c
   trunk/src/rs-library.c
   trunk/src/rs-library.h
Log:
No library backup when indexing thumbnails, and only backup once when manually 
adding tags.

Modified: trunk/src/rs-actions.c
===================================================================
--- trunk/src/rs-actions.c      2010-04-02 23:08:50 UTC (rev 3321)
+++ trunk/src/rs-actions.c      2010-04-03 00:26:02 UTC (rev 3322)
@@ -653,7 +653,7 @@
                        rs_library_photo_add_tag(library, 
g_list_nth_data(selected, cur), tag, FALSE);
                g_free(tag);
        }
-
+       rs_library_backup_tags(library, g_list_nth_data(selected, 
num_selected-1));
        GdkWindow *window = gtk_widget_get_parent_window(GTK_WIDGET(entry));
        gdk_window_destroy(window);
 

Modified: trunk/src/rs-library.c
===================================================================
--- trunk/src/rs-library.c      2010-04-02 23:08:50 UTC (rev 3321)
+++ trunk/src/rs-library.c      2010-04-03 00:26:02 UTC (rev 3322)
@@ -93,7 +93,6 @@
 static void library_tag_delete_photos(RSLibrary *library, const gint tag_id);
 static gboolean library_tag_is_used(RSLibrary *library, const gint tag_id);
 static void library_photo_default_tags(RSLibrary *library, const gint 
photo_id, RSMetadata *metadata);
-static void library_backup_tags(RSLibrary *library, const gchar *directory);
 
 static GtkWidget *tag_search_entry = NULL;
 
@@ -460,8 +459,6 @@
 
        rs_io_idle_read_checksum(filename, -1, got_checksum, 
GINT_TO_POINTER(id));
 
-       library_backup_tags(library, filename);
-
        return id;
 }
 
@@ -626,8 +623,6 @@
        if (!library_is_photo_tagged(library, photo_id, tag_id))
                library_photo_add_tag(library, photo_id, tag_id, autotag);
 
-       library_backup_tags(library, filename);
-
        return;
 }
 
@@ -647,7 +642,7 @@
 
        library_photo_delete_tags(library, photo_id);
        library_delete_photo(library, photo_id);
-       library_backup_tags(library, photo);
+       rs_library_backup_tags(library, photo);
 }
 
 gboolean
@@ -1105,11 +1100,12 @@
 
        gint photo_id = library_add_photo(library, photo);
        library_photo_default_tags(library, photo_id, metadata);
-       library_backup_tags(library, photo);
 }
 
-static void 
-library_backup_tags(RSLibrary *library, const gchar *photo_filename)
+static GStaticMutex backup_lock = G_STATIC_MUTEX_INIT;
+
+void 
+rs_library_backup_tags(RSLibrary *library, const gchar *photo_filename)
 {
        sqlite3 *db = library->db;
        sqlite3_stmt *stmt;
@@ -1119,6 +1115,8 @@
        gchar *directory = g_path_get_dirname(photo_filename);
        gchar *dotdir = rs_dotdir_get(photo_filename);
 
+       g_static_mutex_lock (&backup_lock);
+
        if (!dotdir)
                return;
        GString *gs = g_string_new(dotdir);
@@ -1135,11 +1133,12 @@
                g_free(directory);
                g_free(dotdir);
                g_free(xmlfile);
+               g_static_mutex_unlock (&backup_lock);   
                return;
        }
 
        xmlTextWriterSetIndent(writer, 1);
-       xmlTextWriterStartDocument(writer, NULL, "ISO-8859-1", NULL);
+       xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
        xmlTextWriterStartElement(writer, BAD_CAST "rawstudio-tags");
        xmlTextWriterWriteFormatAttribute(writer, BAD_CAST "version", "%d", 
LIBRARY_VERSION);
 
@@ -1177,6 +1176,7 @@
        g_free(directory);
        g_free(dotdir);
        g_free(xmlfile);
+       g_static_mutex_unlock (&backup_lock);   
        return;
 }
 

Modified: trunk/src/rs-library.h
===================================================================
--- trunk/src/rs-library.h      2010-04-02 23:08:50 UTC (rev 3321)
+++ trunk/src/rs-library.h      2010-04-03 00:26:02 UTC (rev 3322)
@@ -57,6 +57,7 @@
 gboolean rs_library_set_tag_search(gchar *str);
 void rs_library_add_photo_with_metadata(RSLibrary *library, const gchar 
*photo, RSMetadata *metadata);
 void rs_library_restore_tags(const gchar *directory);
+void rs_library_backup_tags(RSLibrary *library, const gchar *photo_filename);
 
 G_END_DECLS
 


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to