diff --git a/ChangeLog b/ChangeLog
index 576da3e..3eab519 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-06-23  Ruben Vermeersch  <ruben@savanne.be>
+
+	* src/TagCommands.cs: Use the new overload when a tag has been edited.
+	Only write XMP metadata when the name has actually changed.
+
+2007-06-23  Ruben Vermeersch  <ruben@savanne.be>
+
+	* src/TagStore.cs: Add a Commit method which writes XMP tags of the
+	associated images. Fixes bgo #327107.
+
 2007-06-19  Priit Laes  <plaes@svn.gnome.org>
 
 	* src/HigMessageDialog.cs: Show underlines in filenames properly,
diff --git a/src/TagCommands.cs b/src/TagCommands.cs
index a2f5bd7..4a17791 100644
--- a/src/TagCommands.cs
+++ b/src/TagCommands.cs
@@ -298,7 +298,7 @@ public class TagCommands {
 					t.Category = categories [category_option_menu.History] as Category;
 					t.Icon = icon_image.Pixbuf;
 
-					db.Tags.Commit (t);
+					db.Tags.Commit (t, orig_name != t.Name);
 					success = true;
 				} catch (Exception ex) {
 					// FIXME error dialog.
diff --git a/src/TagStore.cs b/src/TagStore.cs
index 6cec9eb..e3afa61 100644
--- a/src/TagStore.cs
+++ b/src/TagStore.cs
@@ -7,6 +7,8 @@ using System.Collections;
 using System.IO;
 using System;
 using Banshee.Database;
+using FSpot;
+using FSpot.Jobs;
 using FSpot.Query;
 
 // FIXME: This is to workaround the currently busted GTK# bindings.
@@ -535,8 +537,12 @@ public class TagStore : DbStore {
 
 	public override void Commit (DbItem item)
 	{
-		Tag tag = item as Tag;
+		Commit (item, false);	
+	}
 
+	public void Commit (DbItem item, bool update_xmp)
+	{
+		Tag tag = item as Tag;
 
 		Database.ExecuteNonQuery (new DbCommand ("UPDATE tags SET name = :name, category_id = :category_id, "
                     + "is_category = :is_category, sort_priority = :sort_priority, icon = :icon WHERE id = :id",
@@ -546,12 +552,20 @@ public class TagStore : DbStore {
 						  "sort_priority", tag.SortPriority,
 						  "icon", GetIconString (tag),
 						  "id", tag.Id));
-
 		
 		EmitChanged (tag);
+
+		Console.WriteLine("Doing write: {0}, {1}", update_xmp, Preferences.Get(Preferences.METADATA_EMBED_IN_IMAGE));
+		if (update_xmp && (bool)Preferences.Get(Preferences.METADATA_EMBED_IN_IMAGE)) {
+			Photo [] photos = Core.Database.Photos.Query (new Tag [] { tag });
+			foreach (Photo p in photos) {
+				SyncMetadataJob.Create (Core.Database.Jobs, p);
+			}
+		}
 	}
 
 
+
 #if TEST_TAG_STORE
 
 	private static void Dump (Category category, int indent)
