[meld/meld-3-20] iohelpers: Handle trash-related errors with NFS mounts (#268)



commit 53ded6b47b96736f063efa1a2c19ae219c6a1391
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Wed Jan 9 08:35:30 2019 +1000

    iohelpers: Handle trash-related errors with NFS mounts (#268)
    
    NFS gives a different error code to other network mounts for some
    reason. Annoyingly, it's a generic error code so while I'm hesitant to
    blanket handle it like this... really we're putting up a confirmation
    dialog here so it's not the worst thing.

 meld/iohelpers.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/meld/iohelpers.py b/meld/iohelpers.py
index 211e9bbf..e938683e 100644
--- a/meld/iohelpers.py
+++ b/meld/iohelpers.py
@@ -23,9 +23,15 @@ def trash_or_confirm(gfile: Gio.File):
         gfile.trash(None)
         return True
     except GLib.GError as e:
-        # Only handle not-supported, as that's due to trashing
-        # the target mount-point, not an underlying problem.
-        if e.code != Gio.IOErrorEnum.NOT_SUPPORTED:
+        # Handle not-supported, as that's due to the trashing target
+        # being a (probably network) mount-point, not an underlying
+        # problem. We also have to handle the generic FAILED code
+        # because that's what we get with NFS mounts.
+        expected_error = (
+            e.code == Gio.IOErrorEnum.NOT_SUPPORTED or
+            e.code == Gio.IOErrorEnum.FAILED
+        )
+        if not expected_error:
             raise RuntimeError(str(e))
 
     file_type = gfile.query_file_type(


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