[gnac/devel] Handled properly cases when source and destination files are identical



commit 706c3f1b3aa5870873d092fa450efbe14ca0d976
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Sat Jul 10 13:13:25 2010 +0100

    Handled properly cases when source and destination files are identical

 libgnac/libgnac-converter.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/libgnac/libgnac-converter.c b/libgnac/libgnac-converter.c
index c3512b7..3dd57ee 100644
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@ -962,8 +962,22 @@ libgnac_converter_error_sink(LibgnacMediaItem *item,
   }
 
   /* The destination file already exists */
-  if (g_file_test(g_file_get_path(item->destination), G_FILE_TEST_EXISTS))
+  gchar *dst_path;
+  dst_path = g_file_get_path(item->destination);
+  if (g_file_test(dst_path, G_FILE_TEST_EXISTS))
   {
+    gchar *src_path;
+    src_path = g_file_get_path(item->source);
+    if (g_str_equal(dst_path, src_path)) {
+      const gchar *msg = _("Source and destination files are identical");
+      libgnac_debug(msg);
+      g_signal_emit(item->parent, signals[ERROR], 0, uri, msg, NULL);
+      g_free(dst_path);
+      g_free(src_path);
+      return FALSE;
+    }
+    g_free(src_path);
+
     libgnac_debug("Destination file already exists");
 
     gboolean overwrite = FALSE;
@@ -1013,6 +1027,8 @@ libgnac_converter_error_sink(LibgnacMediaItem *item,
                       _("Unable to access destination file"), error);
   }
 
+  g_free(dst_path);
+
   return FALSE;
 }
 



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