[CalendarServer-changes] [14525] CalendarServer/branches/users/sagen/trashcan-5

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 6 17:03:31 PST 2015


Revision: 14525
          http://trac.calendarserver.org//changeset/14525
Author:   sagen at apple.com
Date:     2015-03-06 17:03:31 -0800 (Fri, 06 Mar 2015)
Log Message:
-----------
Unshare when deleting collection

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/trashcan-5/calendarserver/tools/trash.py
    CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py
    CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py

Modified: CalendarServer/branches/users/sagen/trashcan-5/calendarserver/tools/trash.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/calendarserver/tools/trash.py	2015-03-06 23:57:26 UTC (rev 14524)
+++ CalendarServer/branches/users/sagen/trashcan-5/calendarserver/tools/trash.py	2015-03-07 01:03:31 UTC (rev 14525)
@@ -156,7 +156,6 @@
         print("No untrashed collections for:", prettyRecord(record))
         returnValue(None)
 
-    # print("Listing trashed collections for:", prettyRecord(record))
     for collection in untrashedCollections:
         displayName = displayNameForCollection(collection)
         children = yield trash.trashForCollection(collection._resourceID)
@@ -254,7 +253,6 @@
         returnValue(None)
 
     endTime = datetime.datetime.utcnow() - datetime.timedelta(days=-days)
-    # print("Listing trashed collections for:", prettyRecord(record))
     for collection in untrashedCollections:
         displayName = displayNameForCollection(collection)
         children = yield trash.trashForCollection(
@@ -278,34 +276,8 @@
 
     yield txn.commit()
 
-# @inlineCallbacks
-# def restoreFromTrash(store, directory, root, principals):
 
-#     for principalUID in principals:
-#         txn = store.newTransaction(label="Restore trashed events")
-#         home = yield txn.calendarHomeWithUID(principalUID)
-#         if home is None:
-#             continue
-#         trashedCollections = yield home.children(onlyInTrash=True)
-#         for collection in trashedCollections:
-#             displayName = displayNameForCollection(collection)
-#             print("Restoring collection", displayName, collection._resourceID)
-#             yield collection.fromTrash(restoreChildren=True)
-#         # This code is for untrashing all objects:
-#         # names = yield trash.listObjectResources()
-#         # for name in names:
-#         #     cobj = yield trash.calendarObjectWithName(name)
-#         #     print(name, cobj)
 
-#         #     if cobj is not None:
-#         #         # If it's still in the trash, restore it from trash
-#         #         if (yield cobj.isInTrash()):
-#         #             print("Restoring:", name)
-#         #             yield cobj.fromTrash()
-
-#         yield txn.commit()
-
-
 def displayNameForCollection(collection):
     try:
         displayName = collection.properties()[

Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py	2015-03-06 23:57:26 UTC (rev 14524)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py	2015-03-07 01:03:31 UTC (rev 14525)
@@ -5906,7 +5906,8 @@
         resources = []
         for (objectResourceID,) in results:
             resource = yield self.objectResourceWithID(objectResourceID)
-            resources.append(resource)
+            if resource is not None:
+                resources.append(resource)
         returnValue(resources)
 
 

Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py	2015-03-06 23:57:26 UTC (rev 14524)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py	2015-03-07 01:03:31 UTC (rev 14525)
@@ -6162,6 +6162,8 @@
     @inlineCallbacks
     def toTrash(self):
         # print("XYZZY collection toTrash")
+        yield self.ownerDeleteShare()
+
         for resource in (yield self.objectResources()):
             yield resource.toTrash()
         whenTrashed = datetime.datetime.utcnow()
@@ -7661,6 +7663,8 @@
         originalCollection = self._parentCollection._resourceID
         trash = yield self._parentCollection._home.childWithName("trash")
         newName = str(uuid4())
+        # FIXME: if the sharee is deleting this resource, it needs to move to
+        # the sharer's trash instead
         yield self.moveTo(trash, name=newName)
         yield self._updateToTrashQuery.on(
             self._txn, originalCollection=originalCollection, trashed=datetime.datetime.utcnow(), resourceID=self._resourceID
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150306/ad67dc58/attachment-0001.html>


More information about the calendarserver-changes mailing list