[CalendarServer-changes] [6958] CalendarServer/branches/users/glyph/dalify/txdav

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 16 06:30:56 PST 2011


Revision: 6958
          http://trac.macosforge.org/projects/calendarserver/changeset/6958
Author:   glyph at apple.com
Date:     2011-02-16 06:30:56 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify re-set-quota-to-zero

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/common.py
    CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py

Modified: CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/common.py	2011-02-16 14:30:44 UTC (rev 6957)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/common.py	2011-02-16 14:30:56 UTC (rev 6958)
@@ -822,6 +822,10 @@
         home2 = yield self.homeUnderTest()
         afterQuota = yield home2.quotaUsedBytes()
         self.assertEqual(afterQuota - initialQuota, 30)
+        yield home2.adjustQuotaUsedBytes(-100000)
+        yield self.commit()
+        home3 = yield self.homeUnderTest()
+        self.assertEqual((yield home3.quotaUsedBytes()), 0)
 
 
     @inlineCallbacks

Modified: CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:30:44 UTC (rev 6957)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:30:56 UTC (rev 6958)
@@ -853,6 +853,13 @@
                       Return=meta.QUOTA_USED_BYTES)
 
 
+    @classproperty
+    def _resetQuotaQuery(cls):
+        meta = cls._homeMetaDataSchema
+        return Update({meta.QUOTA_USED_BYTES: 0},
+                      Where=meta.resourceID == Parameter("resourceID"))
+
+
     @inlineCallbacks
     def adjustQuotaUsedBytes(self, delta):
         """
@@ -869,14 +876,11 @@
 
         # Double check integrity
         if self._quotaUsedBytes < 0:
-            log.error("Fixing quota adjusted below zero to %s by change amount %s" % (self._quotaUsedBytes, delta,))
-            yield self._txn.execSQL("""
-                update %(name)s
-                set %(column_QUOTA_USED_BYTES)s = 0
-                where %(column_RESOURCE_ID)s = %%s
-                """ % self._homeMetaDataTable,
-                [self._resourceID]
-            )
+            log.error(
+                "Fixing quota adjusted below zero to %s by change amount %s" %
+                (self._quotaUsedBytes, delta,))
+            yield self._resetQuotaQuery.on(self._txn,
+                                           resourceID=self._resourceID)
             self._quotaUsedBytes = 0
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/af234912/attachment-0001.html>


More information about the calendarserver-changes mailing list