[CalendarServer-changes] [7614] CalendarServer/branches/users/glyph/quota/txdav/caldav/datastore/ file.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Jun 20 11:43:41 PDT 2011


Revision: 7614
          http://trac.macosforge.org/projects/calendarserver/changeset/7614
Author:   glyph at apple.com
Date:     2011-06-20 11:43:40 -0700 (Mon, 20 Jun 2011)
Log Message:
-----------
make file implementation honor quota too (sort of)

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/quota/txdav/caldav/datastore/file.py

Modified: CalendarServer/branches/users/glyph/quota/txdav/caldav/datastore/file.py
===================================================================
--- CalendarServer/branches/users/glyph/quota/txdav/caldav/datastore/file.py	2011-06-20 18:43:29 UTC (rev 7613)
+++ CalendarServer/branches/users/glyph/quota/txdav/caldav/datastore/file.py	2011-06-20 18:43:40 UTC (rev 7614)
@@ -31,7 +31,7 @@
 
 from errno import ENOENT
 
-from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.internet.defer import inlineCallbacks, returnValue, succeed, fail
 
 from twisted.python.failure import Failure
 
@@ -63,6 +63,7 @@
 from txdav.common.datastore.file import (
     CommonDataStore, CommonStoreTransaction, CommonHome, CommonHomeChild,
     CommonObjectResource, CommonStubResource)
+from txdav.caldav.icalendarstore import QuotaExceeded
 
 from txdav.common.icommondatastore import (NoSuchObjectResourceError,
     InternalDataStoreError)
@@ -602,9 +603,13 @@
 
 
     def loseConnection(self):
-
+        home = self._attachment._calendarObject._calendar._home
         oldSize = self._attachment.size()
 
+        if home.quotaAllowedBytes() < ((home.quotaUsedBytes())
+                                       + (self._file.tell() - oldSize)):
+            return fail(QuotaExceeded())
+
         # FIXME: do anything
         self._file.close()
 
@@ -616,10 +621,11 @@
         props[md5key] = TwistedGETContentMD5.fromString(md5)
 
         # Adjust quota
-        self._attachment._calendarObject._calendar._home.adjustQuotaUsedBytes(
+        home.adjustQuotaUsedBytes(
             self._attachment.size() - oldSize
         )
         props.flush()
+        return succeed(None)
 
 
     def getPeer(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110620/3bf04679/attachment-0001.html>


More information about the calendarserver-changes mailing list