Commits

Brodie Rao committed fb45176

Refreshing queue

Comments (0)

Files changed (1)

          if nlink == 0:
              self._fixfilemode(f)
          return fp
-@@ -400,6 +412,97 @@ class vfs(abstractvfs):
+@@ -400,6 +412,98 @@ class vfs(abstractvfs):
          else:
              return self.base
  
 +    _filecls = None
 +
 +if _filecls is not None:
-+    class _zombiefile(file):
++    class _cachedfile(file):
 +        def close(self):
 +            self.flush()
 +
 +        def _close(self):
-+            super(_zombiefile, self).close()
++            super(_cachedfile, self).close()
 +else:
-+    class _zombiefile(object):
++    class _cachedfile(object):
 +        def __init__(self, *args, **kwargs):
 +            fp = util.posixfile(*args, **kwargs)
-+            super(_zombiefile, self).__setattr__('_fp', fp)
++            super(_cachedfile, self).__setattr__('_fp', fp)
 +
 +        def __getattribute__(self, attr):
 +            if attr in ('_fp', 'close', '_close'):
-+                return super(_zombiefile, self).__getattribute__(attr)
++                return super(_cachedfile, self).__getattribute__(attr)
 +            return getattr(self._fp, attr)
 +
 +        def __setattr__(self, attr, val):
 +        super(cachedvfs, self).__init__(*args, **kwargs)
 +        self._fpcache = {}
 +
-+    def _zombiefile(self, f, mode):
-+        fp = _zombiefile(f, mode)
++    def _cachedfile(self, f, mode):
++        print repr(_cachedfile)
++        fp = _cachedfile(f, mode)
 +        st = os.stat(f)
 +        self._fpcache[(f, mode)] = (fp, st)
 +        return fp
 +
 +        entry = self._fpcache.get((f, mode))
 +        if entry is None:
-+            return self._zombiefile(f, mode)
++            return self._cachedfile(f, mode)
 +
 +        fp, st = entry
 +        try:
 +            if e.errno != errno.ENOENT:
 +                raise
 +            fp.close()
-+            return self._zombiefile(f, mode)
++            return self._cachedfile(f, mode)
 +
-+        if not os.path.samestat(st, st2):
++        if not util.samestat(st, st2):
 +            del self._fpcache[(f, mode)]
 +            fp.close()
-+            return self._zombiefile(f, mode)
++            return self._cachedfile(f, mode)
 +
 +        try:
 +            fp.flush()
 +            if e.errno != errno.ESTALE:
 +                raise
 +            fp.close()
-+            return self._zombiefile(f, mode)
++            return self._cachedfile(f, mode)
 +
 +        return fp
 +
  opener = vfs
  
  class auditvfs(object):
-@@ -424,6 +527,9 @@ class filtervfs(abstractvfs, auditvfs):
+@@ -424,6 +528,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 +549,8 @@ class readonlyvfs(abstractvfs, auditvfs)
+@@ -443,6 +550,8 @@ class readonlyvfs(abstractvfs, auditvfs)
              raise util.Abort('this vfs is read only')
          return self.vfs(path, mode, *args, **kw)