[CalendarServer-changes] [5960] CalendarServer/branches/users/wsanchez/deployment-pre-partition/ lib-patches/Twisted/twisted.python.filepath.patch
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 29 10:33:13 PDT 2010
Revision: 5960
http://trac.macosforge.org/projects/calendarserver/changeset/5960
Author: glyph at apple.com
Date: 2010-07-29 10:33:13 -0700 (Thu, 29 Jul 2010)
Log Message:
-----------
Reduce the amount of work being done by FilePath.child, by avoiding calls to 'normpath' and 'joinpath' (as these are not necessary on POSIX OSes).
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/deployment-pre-partition/lib-patches/Twisted/twisted.python.filepath.patch
Modified: CalendarServer/branches/users/wsanchez/deployment-pre-partition/lib-patches/Twisted/twisted.python.filepath.patch
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment-pre-partition/lib-patches/Twisted/twisted.python.filepath.patch 2010-07-29 16:53:26 UTC (rev 5959)
+++ CalendarServer/branches/users/wsanchez/deployment-pre-partition/lib-patches/Twisted/twisted.python.filepath.patch 2010-07-29 17:33:13 UTC (rev 5960)
@@ -2,21 +2,57 @@
===================================================================
--- twisted/python/filepath.py (revision 19773)
+++ twisted/python/filepath.py (working copy)
-@@ -286,9 +286,11 @@
+@@ -253,7 +253,10 @@
+ return int(self.getStatusChangeTime())
+
+
++def passthru(x):
++ return x
+
++
+ class FilePath(_PathHelper):
+ """
+ I am a path on the filesystem that only permits 'downwards' access.
+@@ -286,9 +289,11 @@
statinfo = None
path = None
- def __init__(self, path, alwaysCreate=False):
-+ def __init__(self, path, alwaysCreate=False, existsCached=None, isDirCached=None):
- self.path = abspath(path)
+- self.path = abspath(path)
++ def __init__(self, path, alwaysCreate=False, existsCached=None, isDirCached=None, normalizer=abspath):
++ self.path = normalizer(path)
self.alwaysCreate = alwaysCreate
+ self.existsCached = existsCached
+ self.isDirCached = isDirCached
def __getstate__(self):
d = self.__dict__.copy()
-@@ -370,6 +372,11 @@
+@@ -297,17 +302,16 @@
+ return d
+ def child(self, path):
+- if platform.isWindows() and path.count(":"):
+- # Catch paths like C:blah that don't have a slash
+- raise InsecurePath("%r contains a colon." % (path,))
+- norm = normpath(path)
+- if slash in norm:
++ if slash in path:
+ raise InsecurePath("%r contains one or more directory separators" % (path,))
+- newpath = abspath(joinpath(self.path, norm))
+- if not newpath.startswith(self.path):
++ newpath = joinpath(self.path, path)
++ if path in ('.', '..'):
+ raise InsecurePath("%r is not a child of %s" % (newpath, self.path))
+ return self.clonePath(newpath)
+
++ def clonePath(self, path):
++ return FilePath(path, normalizer=passthru)
++
+ def preauthChild(self, path):
+ """
+ Use me if `path' might have slashes in it, but you know they're safe.
+@@ -370,6 +374,11 @@
+
# stat methods below
+ def changed(self):
@@ -27,7 +63,7 @@
def restat(self, reraise=True):
"""
Re-calculate cached effects of 'stat'. To refresh information on this path
-@@ -381,11 +388,22 @@
+@@ -381,11 +390,22 @@
"""
try:
self.statinfo = stat(self.path)
@@ -50,7 +86,7 @@
def getsize(self):
st = self.statinfo
if not st:
-@@ -437,7 +455,9 @@
+@@ -437,7 +457,9 @@
def exists(self):
@@ -61,7 +97,7 @@
return True
elif self.statinfo is None:
self.restat(False)
-@@ -446,6 +466,8 @@
+@@ -446,6 +468,8 @@
return False
def isdir(self):
@@ -70,7 +106,7 @@
st = self.statinfo
if not st:
self.restat(False)
-@@ -496,7 +518,7 @@
+@@ -496,7 +520,7 @@
os.rmdir(self.path)
else:
os.remove(self.path)
@@ -79,7 +115,7 @@
def makedirs(self):
return os.makedirs(self.path)
-@@ -600,7 +622,7 @@
+@@ -600,7 +624,7 @@
def moveTo(self, destination):
try:
os.rename(self.path, destination.path)
@@ -88,3 +124,8 @@
except OSError, ose:
if ose.errno == errno.EXDEV:
# man 2 rename, ubuntu linux 5.10 "breezy":
+@@ -623,4 +647,3 @@
+ raise
+
+
+-FilePath.clonePath = FilePath
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100729/8f9a24ba/attachment.html>
More information about the calendarserver-changes
mailing list