[meld] vc._vc: Fix entry handling for missing files (bgo#786043)



commit eed3b9a23758fa7a8c75cd99411a309151c21f3b
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Thu Aug 10 07:00:20 2017 +1000

    vc._vc: Fix entry handling for missing files (bgo#786043)
    
    This handling was broken from some Gio migration, and simply tracebacked
    if the query_info() was run on a non-existant file.

 meld/vc/_vc.py |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index d87628e..5c0aa7a 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -32,6 +32,7 @@ import subprocess
 import tempfile
 
 from gi.repository import Gio
+from gi.repository import GLib
 
 from meld.conf import _
 
@@ -309,14 +310,21 @@ class Vc(object):
         MISSING state.
         """
         gfile = Gio.File.new_for_path(path)
-        file_info = gfile.query_info(
-            'standard::*', Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, None)
+        try:
+            file_info = gfile.query_info(
+                'standard::*', Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, None)
+            name = file_info.get_display_name()
+            isdir = file_info.get_file_type() == Gio.FileType.DIRECTORY
+        except GLib.Error as e:
+            if e.domain != 'g-io-error-quark':
+                raise
+            # Handling for non-existant files (or other IO errors)
+            name = path
+            isdir = False
 
         path = gfile.get_path()
-        name = file_info.get_display_name()
         state = self._tree_cache.get(path, STATE_NORMAL)
         meta = self._tree_meta_cache.get(path, "")
-        isdir = file_info.get_file_type() == Gio.FileType.DIRECTORY
 
         return Entry(path, name, state, isdir, options=meta)
 


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