[CalendarServer-changes] [12745] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:22:31 PDT 2014
Revision: 12745
http://trac.calendarserver.org//changeset/12745
Author: gaya at apple.com
Date: 2014-02-24 11:14:24 -0800 (Mon, 24 Feb 2014)
Log Message:
-----------
use cofig dicts with explicit Enabled for inbox and revision cleanup work
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/stdconfig.py
CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py
CalendarServer/trunk/txdav/common/datastore/work/revision_cleanup.py
CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py
CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2014-02-24 17:56:03 UTC (rev 12744)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2014-02-24 19:14:24 UTC (rev 12745)
@@ -634,12 +634,18 @@
"RemoveDuplicatePrivateComments": False, # Remove duplicate private comments on PUT
- "SyncTokenLifetimeDays" : 14.0, # Number of days that a client sync report token is valid
- "RevisionCleanupPeriodDays" : 2.0, # Number of days between revision cleanups
+ "RevisionCleanup": {
+ "Enabled": True,
+ "SyncTokenLifetimeDays" : 14.0, # Number of days that a client sync report token is valid
+ "CleanupPeriodDays" : 2.0, # Number of days between revision cleanups
+ },
- "InboxItemLifetimeDays" : 14.0, # Number of days before deleting a new inbox item
- "InboxItemLifetimePastEventEndDays" : 14.0, # Number of days to keep an inbox item past the time when its referenced event ends
- "InboxCleanupPeriodDays" : 2.0, # Number of days between inbox cleanups
+ "InboxCleanup": {
+ "Enabled": True,
+ "ItemLifetimeDays" : 14.0, # Number of days before deleting a new inbox item
+ "ItemLifeBeyondEventEndDays" : 14.0, # Number of days to keep an inbox item past the time when its referenced event ends
+ "CleanupPeriodDays" : 2.0, # Number of days between inbox cleanups
+ },
# CardDAV Features
"DirectoryAddressBook": {
Modified: CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py 2014-02-24 17:56:03 UTC (rev 12744)
+++ CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py 2014-02-24 19:14:24 UTC (rev 12745)
@@ -76,7 +76,7 @@
# Schedule next check
yield self._schedule(
self.transaction,
- float(config.InboxCleanupPeriodDays) * 24 * 60 * 60
+ float(config.InboxCleanup.CleanupPeriodDays) * 24 * 60 * 60
)
@@ -111,8 +111,8 @@
homeID=self.uid(), orphanNames=orphanNames))
# get old item names
- if float(config.InboxItemLifetimeDays) >= 0: # use -1 to disable; 0 is test case
- cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=float(config.InboxItemLifetimeDays))
+ if float(config.InboxCleanup.ItemLifetimeDays) >= 0: # use -1 to disable; 0 is test case
+ cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=float(config.InboxCleanup.ItemLifetimeDays))
oldItemNames = set((
yield self.transaction.listInboxItemsInHomeCreatedBefore(self.homeID, cutoff)
))
@@ -125,8 +125,8 @@
oldItemNames = set()
# get item name for old events
- if float(config.InboxItemLifetimePastEventEndDays) >= 0: # use -1 to disable; 0 is test case
- cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=float(config.InboxItemLifetimePastEventEndDays))
+ if float(config.InboxCleanup.ItemLifeBeyondEventEndDays) >= 0: # use -1 to disable; 0 is test case
+ cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=float(config.InboxCleanup.ItemLifeBeyondEventEndDays))
itemNamesForOldEvents = set((
yield self.transaction.listInboxItemsInHomeForEventsBefore(self.homeID, cutoff)
))
@@ -148,7 +148,10 @@
@inlineCallbacks
def scheduleFirstInboxCleanup(store, seconds):
- txn = store.newTransaction()
- wp = yield InboxCleanupWork._schedule(txn, seconds)
- yield txn.commit()
- returnValue(wp)
+ if config.InboxCleanup.Enabled:
+ txn = store.newTransaction()
+ wp = yield InboxCleanupWork._schedule(txn, seconds)
+ yield txn.commit()
+ returnValue(wp)
+ else:
+ log.debug("Inbox cleanup work disabled.")
Modified: CalendarServer/trunk/txdav/common/datastore/work/revision_cleanup.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/work/revision_cleanup.py 2014-02-24 17:56:03 UTC (rev 12744)
+++ CalendarServer/trunk/txdav/common/datastore/work/revision_cleanup.py 2014-02-24 19:14:24 UTC (rev 12745)
@@ -56,7 +56,7 @@
# get max revision on table rows before dateLimit
dateLimit = (datetime.datetime.utcnow() -
- datetime.timedelta(days=float(config.SyncTokenLifetimeDays)))
+ datetime.timedelta(days=float(config.RevisionCleanup.SyncTokenLifetimeDays)))
maxRevOlderThanDate = 0
# TODO: Use one Select statement
@@ -88,7 +88,7 @@
# Schedule next check
yield FindMinValidRevisionWork._schedule(
self.transaction,
- float(config.RevisionCleanupPeriodDays) * 24 * 60 * 60
+ float(config.RevisionCleanup.CleanupPeriodDays) * 24 * 60 * 60
)
@@ -122,14 +122,17 @@
# Schedule next update
yield FindMinValidRevisionWork._schedule(
self.transaction,
- float(config.RevisionCleanupPeriodDays) * 24 * 60 * 60
+ float(config.RevisionCleanup.CleanupPeriodDays) * 24 * 60 * 60
)
@inlineCallbacks
def scheduleFirstFindMinRevision(store, seconds):
- txn = store.newTransaction()
- wp = yield FindMinValidRevisionWork._schedule(txn, seconds)
- yield txn.commit()
- returnValue(wp)
+ if config.RevisionCleanup.Enabled:
+ txn = store.newTransaction()
+ wp = yield FindMinValidRevisionWork._schedule(txn, seconds)
+ yield txn.commit()
+ returnValue(wp)
+ else:
+ log.debug("Revision cleanup work disabled.")
Modified: CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py 2014-02-24 17:56:03 UTC (rev 12744)
+++ CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py 2014-02-24 19:14:24 UTC (rev 12745)
@@ -170,8 +170,8 @@
"""
Verify that orphaned Inbox items are removed
"""
- self.patch(config, "InboxItemLifetimeDays", -1)
- self.patch(config, "InboxItemLifetimePastEventEndDays", -1)
+ self.patch(config.InboxCleanup, "ItemLifetimeDays", -1)
+ self.patch(config.InboxCleanup, "ItemLifeBeyondEventEndDays", -1)
#create orphans by deleting events
inbox = yield self.calendarUnderTest(home="user01", name="inbox")
@@ -195,11 +195,11 @@
"""
Verify that old inbox items are removed
"""
- self.patch(config, "InboxItemLifetimePastEventEndDays", -1)
+ self.patch(config.InboxCleanup, "ItemLifeBeyondEventEndDays", -1)
# Predate some inbox items
inbox = yield self.calendarUnderTest(home="user01", name="inbox")
- oldDate = datetime.datetime.utcnow() - datetime.timedelta(days=float(config.InboxItemLifetimeDays), seconds=10)
+ oldDate = datetime.datetime.utcnow() - datetime.timedelta(days=float(config.InboxCleanup.ItemLifetimeDays), seconds=10)
itemsToPredate = ["cal2.ics", "cal3.ics"]
co = schema.CALENDAR_OBJECT
Modified: CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py 2014-02-24 17:56:03 UTC (rev 12744)
+++ CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py 2014-02-24 19:14:24 UTC (rev 12745)
@@ -50,7 +50,7 @@
self.patch(FindMinValidRevisionWork, "_schedule", FakeWork._schedule)
self.patch(RevisionCleanupWork, "_schedule", FakeWork._schedule)
- self.patch(config, "SyncTokenLifetimeDays", 0)
+ self.patch(config.RevisionCleanup, "SyncTokenLifetimeDays", 0)
@inlineCallbacks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/07ada931/attachment.html>
More information about the calendarserver-changes
mailing list