[CalendarServer-changes] [14803] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue May 19 14:15:30 PDT 2015


Revision: 14803
          http://trac.calendarserver.org//changeset/14803
Author:   sagen at apple.com
Date:     2015-05-19 14:15:30 -0700 (Tue, 19 May 2015)
Log Message:
-----------
Added 'recovertrash' action to calendar home

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/resource.py
    CalendarServer/trunk/txdav/common/datastore/sql.py

Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py	2015-05-19 20:05:17 UTC (rev 14802)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2015-05-19 21:15:30 UTC (rev 14803)
@@ -2756,6 +2756,14 @@
                 self._ok("ok", "Trash Contents", contents)
             )
 
+        elif action == "recovertrash":
+            mode = request.args.get("mode", ("event",))[0]
+            recoveryID = int(request.args.get("id", ("0",))[0])
+            yield self._newStoreHome.recoverTrash(mode, recoveryID)
+            returnValue(
+                self._ok("ok", "Recover Trash")
+            )
+
         else:
             raise HTTPError(ErrorResponse(
                 responsecode.FORBIDDEN,

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py	2015-05-19 20:05:17 UTC (rev 14802)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py	2015-05-19 21:15:30 UTC (rev 14803)
@@ -3121,7 +3121,24 @@
         returnValue(result)
 
 
+    @inlineCallbacks
+    def recoverTrash(self, mode, recoveryID):
+        trash = yield self.getTrash()
+        if trash is not None:
 
+            if mode == "event":
+                child = yield trash.objectResourceWithID(recoveryID)
+                if child is not None:
+                    yield child.fromTrash()
+
+            else:
+                collection = yield self.childWithID(recoveryID, onlyInTrash=True)
+                if collection is not None:
+                    yield collection.fromTrash(
+                        restoreChildren=True, delta=datetime.timedelta(minutes=5)
+                    )
+
+
 class CommonHomeChild(FancyEqMixin, Memoizable, _SharedSyncLogic, HomeChildBase, SharingMixIn):
     """
     Common ancestor class of AddressBooks and Calendars.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150519/e26bf080/attachment.html>


More information about the calendarserver-changes mailing list