[gthumb] Fixed automatic creation of comments from embedded data



commit afd1f42d11fddfa625908cc89dd63a1c21136178
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed May 25 22:31:26 2011 +0200

    Fixed automatic creation of comments from embedded data
    
    ensure the comment directory is present before saving the comment file

 extensions/comments/main.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/extensions/comments/main.c b/extensions/comments/main.c
index 83f2224..3d2bae4 100644
--- a/extensions/comments/main.c
+++ b/extensions/comments/main.c
@@ -175,11 +175,16 @@ comments__read_metadata_ready_cb (GthFileData *file_data,
 
 	if (write_comment) {
 		GFile *comment_file;
+		GFile *comment_directory;
 		char  *buffer;
 		gsize  size;
 
-		buffer = gth_comment_to_data (comment, &size);
 		comment_file = gth_comment_get_comment_file (file_data->file);
+		comment_directory = g_file_get_parent (comment_file);
+		if (! g_file_query_exists (comment_directory, NULL))
+			g_file_make_directory (comment_directory, NULL, NULL);
+
+		buffer = gth_comment_to_data (comment, &size);
 		g_write_file (comment_file,
 			      FALSE,
 			      G_FILE_CREATE_NONE,
@@ -188,8 +193,9 @@ comments__read_metadata_ready_cb (GthFileData *file_data,
 			      NULL,
 			      NULL);
 
-		g_object_unref (comment_file);
 		g_free (buffer);
+		g_object_unref (comment_directory);
+		g_object_unref (comment_file);
 	}
 
 	g_object_unref (comment);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]