##// END OF EJS Templates
vfs: copy if EPERM to avoid file stat ambiguity forcibly at closing...
FUJIWARA Katsunori -
r33280:64635229 default
parent child Browse files
Show More
@@ -22,6 +22,23 b' from . import ('
22 util,
22 util,
23 )
23 )
24
24
25 def _avoidambig(path, oldstat):
26 """Avoid file stat ambiguity forcibly
27
28 This function causes copying ``path`` file, if it is owned by
29 another (see issue5418 and issue5584 for detail).
30 """
31 def checkandavoid():
32 newstat = util.filestat.frompath(path)
33 # return whether file stat ambiguity is (already) avoided
34 return (not newstat.isambig(oldstat) or
35 newstat.avoidambig(path, oldstat))
36 if not checkandavoid():
37 # simply copy to change owner of path to get privilege to
38 # advance mtime (see issue5418)
39 util.rename(util.mktempcopy(path), path)
40 checkandavoid()
41
25 class abstractvfs(object):
42 class abstractvfs(object):
26 """Abstract base class; cannot be instantiated"""
43 """Abstract base class; cannot be instantiated"""
27
44
@@ -613,10 +630,7 b' class checkambigatclosing(closewrapbase)'
613 def _checkambig(self):
630 def _checkambig(self):
614 oldstat = self._oldstat
631 oldstat = self._oldstat
615 if oldstat.stat:
632 if oldstat.stat:
616 newstat = util.filestat.frompath(self._origfh.name)
633 _avoidambig(self._origfh.name, oldstat)
617 if newstat.isambig(oldstat):
618 # stat of changed file is ambiguous to original one
619 newstat.avoidambig(self._origfh.name, oldstat)
620
634
621 def __exit__(self, exc_type, exc_value, exc_tb):
635 def __exit__(self, exc_type, exc_value, exc_tb):
622 self._origfh.__exit__(exc_type, exc_value, exc_tb)
636 self._origfh.__exit__(exc_type, exc_value, exc_tb)
General Comments 0
You need to be logged in to leave comments. Login now