[glib] On trash, if rename fails with EXDEV, return G_IO_ERROR_NOT_SUPPORTED



commit 1ce74b0dd34222b201369e5aff53b27182db7b66
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Apr 2 19:01:56 2009 +0200

    On trash, if rename fails with EXDEV, return G_IO_ERROR_NOT_SUPPORTED
    
    Sometimes it seems like the trash dir and the file are on the same
    filesystem but the rename fails with EXDEV anyway (can happen
    e.g. with bind mounts or multiple mounts of the same device). In this
    case we want to return the right error so that apps can fallback to
    regular delete.
---
 gio/glocalfile.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index b1d7353..098f76e 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -1921,11 +1921,20 @@ g_local_file_trash (GFile         *file,
       g_free (trashname);
       g_free (infofile);
       g_free (trashfile);
-      
-      g_set_error (error, G_IO_ERROR,
-		   g_io_error_from_errno (errsv),
-		   _("Unable to trash file: %s"),
-		   g_strerror (errsv));
+
+      if (errsv == EXDEV)
+	/* The trash dir was actually on another fs anyway!?
+	   This can happen when the same device is mounted multiple
+	   times, or with bind mounts of the same fs. */
+	g_set_error (error, G_IO_ERROR,
+		     G_IO_ERROR_NOT_SUPPORTED,
+		     _("Unable to trash file: %s"),
+		     g_strerror (errsv));
+      else
+	g_set_error (error, G_IO_ERROR,
+		     g_io_error_from_errno (errsv),
+		     _("Unable to trash file: %s"),
+		     g_strerror (errsv));
       return FALSE;
     }
 



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