[CalendarServer-changes] [167] CalendarServer/branches/users/cdaboo/quota

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 21 11:16:42 PDT 2006


Revision: 167
          http://trac.macosforge.org/projects/calendarserver/changeset/167
Author:   cdaboo at apple.com
Date:     2006-09-21 11:16:42 -0700 (Thu, 21 Sep 2006)

Log Message:
-----------
Use FilePath instead of os apis.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/quota/lib-patches/Twisted/twisted.web2.dav.static
    CalendarServer/branches/users/cdaboo/quota/twistedcaldav/static.py

Modified: CalendarServer/branches/users/cdaboo/quota/lib-patches/Twisted/twisted.web2.dav.static
===================================================================
--- CalendarServer/branches/users/cdaboo/quota/lib-patches/Twisted/twisted.web2.dav.static	2006-09-21 17:39:15 UTC (rev 166)
+++ CalendarServer/branches/users/cdaboo/quota/lib-patches/Twisted/twisted.web2.dav.static	2006-09-21 18:16:42 UTC (rev 167)
@@ -2,15 +2,7 @@
 ===================================================================
 --- twisted/web2/dav/static.py	(revision 18209)
 +++ twisted/web2/dav/static.py	(working copy)
-@@ -29,6 +29,7 @@
- __all__ = ["DAVFile"]
- 
- import os
-+import stat
- 
- from twisted.python import log
- from twisted.internet.defer import succeed, deferredGenerator, waitForDeferred
-@@ -98,6 +99,58 @@
+@@ -98,6 +98,57 @@
          return succeed(davPrivilegeSet)
  
      ##
@@ -28,8 +20,7 @@
 +        if self.isCollection():
 +            return self.collectionQuotaUse(request)
 +        else:
-+            result = os.stat(self.fp.path)
-+            return result[stat.ST_SIZE]
++            return self.fp.getsize()
 +
 +    def collectionQuotaUse(self, request):
 +        """
@@ -44,26 +35,26 @@
 +            """
 +            Recursively descend the directory tree rooted at top,
 +            calling the callback function for each regular file
++            
++            @param top: L{FilePath} for the directory to walk.
 +            """
 +        
 +            total = 0
-+            for f in os.listdir(top):
-+                pathname = os.path.join(top, f)
-+                result = os.stat(pathname)
-+                mode = result[stat.ST_MODE]
-+                if stat.S_ISDIR(mode):
++            for f in top.listdir():
++                child = top.child(f)
++                if child.isdir():
 +                    # It's a directory, recurse into it
-+                    total += walktree(pathname)
-+                elif stat.S_ISREG(mode):
++                    total += walktree(child)
++                elif child.isfile():
 +                    # It's a file, call the callback function
-+                    total += result[stat.ST_SIZE]
++                    total += child.getsize()
 +                else:
 +                    # Unknown file type, print a message
 +                    pass
 +        
 +            return total
 +        
-+        return walktree(self.fp.path)
++        return walktree(self.fp)
 +
 +    ##
      # Workarounds for issues with File

Modified: CalendarServer/branches/users/cdaboo/quota/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/cdaboo/quota/twistedcaldav/static.py	2006-09-21 17:39:15 UTC (rev 166)
+++ CalendarServer/branches/users/cdaboo/quota/twistedcaldav/static.py	2006-09-21 18:16:42 UTC (rev 167)
@@ -35,7 +35,6 @@
 
 import os
 import errno
-import stat
 from urlparse import urlsplit
 
 from twisted.internet.defer import deferredGenerator, fail, succeed, waitForDeferred
@@ -330,28 +329,26 @@
             """
         
             total = 0
-            for f in os.listdir(top):
+            for f in top.listdir():
                 
                 # Ignore the database
                 if top_level and f == db_basename:
                     continue
 
-                pathname = os.path.join(top, f)
-                result = os.stat(pathname)
-                mode = result[stat.ST_MODE]
-                if stat.S_ISDIR(mode):
+                child = top.child(f)
+                if child.isdir():
                     # It's a directory, recurse into it
-                    total += walktree(pathname)
-                elif stat.S_ISREG(mode):
+                    total += walktree(child)
+                elif child.isfile():
                     # It's a file, call the callback function
-                    total += result[stat.ST_SIZE]
+                    total += child.getsize()
                 else:
                     # Unknown file type, print a message
                     pass
         
             return total
         
-        return walktree(self.fp.path, True)
+        return walktree(self.fp, True)
 
     ##
     # Utilities

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20060921/84077594/attachment.html


More information about the calendarserver-changes mailing list