Commits

Brodie Rao committed 1a8c620

Refreshing queue

  • Participants
  • Parent commits f8af7c5

Comments (0)

Files changed (1)

          if expandpath:
              base = util.expandpath(base)
          if realpath:
-@@ -328,6 +332,9 @@ class vfs(abstractvfs):
+@@ -328,6 +332,12 @@ class vfs(abstractvfs):
              return
          os.chmod(name, self.createmode & 0666)
  
++    def _invalidate(self, f):
++        pass
++
 +    def _open(self, f, mode):
 +        return util.posixfile(f, mode)
 +
      def __call__(self, path, mode="r", text=False, atomictemp=False):
          if self._audit:
              r = util.checkosfilename(path)
-@@ -370,7 +377,7 @@ class vfs(abstractvfs):
+@@ -350,6 +360,7 @@ class vfs(abstractvfs):
+                     return util.atomictempfile(f, mode, self.createmode)
+                 try:
+                     if 'w' in mode:
++                        self._invalidate(f)
+                         util.unlink(f)
+                         nlink = 0
+                     else:
+@@ -369,8 +380,9 @@ class vfs(abstractvfs):
+                     if self._trustnlink is None:
                          self._trustnlink = nlink > 1 or util.checknlink(f)
                      if nlink > 1 or not self._trustnlink:
++                        self._invalidate(f)
                          util.rename(util.mktempcopy(f), f)
 -        fp = util.posixfile(f, mode)
 +        fp = self._open(f, mode)
          if nlink == 0:
              self._fixfilemode(f)
          return fp
-@@ -400,6 +407,68 @@ class vfs(abstractvfs):
+@@ -400,6 +412,72 @@ class vfs(abstractvfs):
          else:
              return self.base
  
 +            self._fpcache[(f, mode)] = fp
 +        return fp
 +
++    def _invalidate(self, f):
++        for key in [k for k in self._fpcache if k[0] == f]:
++            del self._fpcache[key]
++
 +    def close(self):
 +        for fp in self._fpcache.itervalues():
 +            fp._close()
  opener = vfs
  
  class auditvfs(object):
-@@ -424,6 +493,9 @@ class filtervfs(abstractvfs, auditvfs):
+@@ -424,6 +502,9 @@ class filtervfs(abstractvfs, auditvfs):
      def __call__(self, path, *args, **kwargs):
          return self.vfs(self._filter(path), *args, **kwargs)
  
      def join(self, path):
          if path:
              return self.vfs.join(self._filter(path))
-@@ -443,6 +515,8 @@ class readonlyvfs(abstractvfs, auditvfs)
+@@ -443,6 +524,8 @@ class readonlyvfs(abstractvfs, auditvfs)
              raise util.Abort('this vfs is read only')
          return self.vfs(path, mode, *args, **kw)