[CalendarServer-changes] [11550] CalendarServer/trunk/txdav/caldav/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jul 23 14:42:58 PDT 2013
Revision: 11550
http://trac.calendarserver.org//changeset/11550
Author: cdaboo at apple.com
Date: 2013-07-23 14:42:57 -0700 (Tue, 23 Jul 2013)
Log Message:
-----------
Make sure dropbox directories are removed when empty during migration to managed attachments.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2013-07-23 20:20:41 UTC (rev 11549)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2013-07-23 21:42:57 UTC (rev 11550)
@@ -3589,6 +3589,13 @@
Remove the actual file and up to attachment parent directory if empty.
"""
self._path.remove()
+ self.removeParentPaths()
+
+
+ def removeParentPaths(self):
+ """
+ Remove up to attachment parent directory if empty.
+ """
parent = self._path.parent()
toppath = self._attachmentPathRoot().path
while parent.path != toppath:
@@ -3833,6 +3840,7 @@
oldpath = self._path
newpath = mattach._path
oldpath.moveTo(newpath)
+ self.removeParentPaths()
returnValue(mattach)
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py 2013-07-23 20:20:41 UTC (rev 11549)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py 2013-07-23 21:42:57 UTC (rev 11550)
@@ -1404,7 +1404,9 @@
self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory, directoryFromConfig(config))
yield self.populate()
+ self.paths = {}
+
@inlineCallbacks
def populate(self):
yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
@@ -1446,6 +1448,8 @@
t.write(" attachment")
yield t.loseConnection()
+ self.paths[name] = attachment._path
+
cal = (yield event.componentForUser())
cal.mainComponent().addProperty(Property(
"ATTACH",
@@ -1834,3 +1838,9 @@
yield self._verifyConversion("home2", "calendar2", "2-2.3.ics", ("attach_1_3.txt",))
yield self._verifyConversion("home2", "calendar3", "2-3.2.ics", ("attach_1_4.txt",))
yield self._verifyConversion("home2", "calendar3", "2-3.3.ics", ("attach_1_4.txt",))
+
+ # Paths do not exist
+ for path in self.paths.values():
+ for _ignore in range(4):
+ self.assertFalse(path.exists(), msg="Still exists: %s" % (path,))
+ path = path.parent()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130723/892fb67d/attachment.html>
More information about the calendarserver-changes
mailing list