summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2015-10-27 03:03:12 +0100
committernfnty <git@nfnty.se>2016-02-08 04:43:04 +0100
commit87e473e0921f05b5e66f84d5bdc9e810a65218cc (patch)
tree8bbbcdda03f16341ec099ad09056af1a9a9584c0
parentcf750b5b890d3dd903116459eb621fae1875a5c6 (diff)
downloadranger-87e473e0921f05b5e66f84d5bdc9e810a65218cc.tar.gz
VCS: Fix repo deletion race
-rw-r--r--ranger/ext/vcs/vcs.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index ca16fbbf..a6d12db7 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -158,10 +158,10 @@ class Vcs(object):
         if not self.in_repodir \
                 and (not self.track or (not self.is_root and self.get_repotype(self.path)[0])):
             self.__init__(self.obj)
-            return True
         elif self.track and not os.path.exists(self.repodir):
-            self.purge_tree()
+            self.update_tree(purge=True)
             return False
+        return True
 
     def update_root(self):
         """Update repository"""
@@ -172,12 +172,9 @@ class Vcs(object):
             self.rootvcs.remotestatus = self.rootvcs.get_status_remote()
             self.rootvcs.obj.vcspathstatus = self.rootvcs.get_status_root()
         except VcsError:
-            self.purge_tree()
-
-    def purge_tree(self):
-        """Purge tree"""
-        self.update_tree(purge=True)
-        self.rootvcs.__init__(self.rootvcs.obj)
+            self.update_tree(purge=True)
+            return False
+        return True
 
     def _update_walk(self, path, purge):
         """Update walk"""
@@ -229,11 +226,14 @@ class Vcs(object):
                 continue
             if purge:
                 dirobj.vcspathstatus = None
+                dirobj.vcs.__init__(dirobj.vcs.obj)
             elif dirobj.vcs.path == self.root:
                 dirobj.vcspathstatus = self.rootvcs.get_status_root()
             else:
                 dirobj.vcspathstatus = dirobj.vcs.get_status_subpath(
                     dirobj.path, is_directory=True)
+        if purge:
+            self.rootvcs.__init__(self.rootvcs.obj)
 
     # Action interface
     #---------------------------
@@ -390,9 +390,9 @@ class VcsThread(threading.Thread):
                                  and (clmn.target.path == target.vcs.repodir or
                                       clmn.target.path.startswith(target.vcs.repodir + '/'))):
                             continue
-                        target.vcs.update_root()
-                        target.vcs.update_tree()
-                        redraw = True
+                        if target.vcs.update_root():
+                            target.vcs.update_tree()
+                            redraw = True
 
             if redraw:
                 redraw = False