[CalendarServer-changes] [9870] CalendarServer/trunk/twistedcaldav/storebridge.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 27 14:31:07 PDT 2012


Revision: 9870
          http://trac.calendarserver.org//changeset/9870
Author:   sagen at apple.com
Date:     2012-09-27 14:31:07 -0700 (Thu, 27 Sep 2012)
Log Message:
-----------
If AttachmentRoot is unavailable, attachment PUTs result in 503 response, and transaction is aborted

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/storebridge.py

Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py	2012-09-27 20:43:41 UTC (rev 9869)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py	2012-09-27 21:31:07 UTC (rev 9870)
@@ -45,7 +45,7 @@
 from twext.web2.dav.util import parentForURL, allDataFromStream, joinURL, davXMLFromStream
 from twext.web2.responsecode import (
     FORBIDDEN, NO_CONTENT, NOT_FOUND, CREATED, CONFLICT, PRECONDITION_FAILED,
-    BAD_REQUEST, OK, INSUFFICIENT_STORAGE_SPACE
+    BAD_REQUEST, OK, INSUFFICIENT_STORAGE_SPACE, SERVICE_UNAVAILABLE
 )
 
 from twistedcaldav import customxml, carddavxml, caldavxml
@@ -1601,14 +1601,21 @@
         if content_type is None:
             content_type = MimeType("application", "octet-stream")
 
-        creating = (self._newStoreAttachment is None)
-        if creating:
-            self._newStoreAttachment = self._newStoreObject = (
-                yield self._newStoreCalendarObject.createAttachmentWithName(
-                    self.attachmentName))
-        t = self._newStoreAttachment.store(content_type)
-        yield readStream(request.stream, t.write)
         try:
+            creating = (self._newStoreAttachment is None)
+            if creating:
+                self._newStoreAttachment = self._newStoreObject = (
+                    yield self._newStoreCalendarObject.createAttachmentWithName(
+                        self.attachmentName))
+            t = self._newStoreAttachment.store(content_type)
+            yield readStream(request.stream, t.write)
+        except Exception, e:
+            log.error("Unable to store attachment: %s" % (e,))
+            # Signal to abort in twistedcaldav.resource.CalDAVResource.RenderHTTP
+            self.transactionError()
+            raise HTTPError(SERVICE_UNAVAILABLE)
+
+        try:
             yield t.loseConnection()
         except QuotaExceeded:
             raise HTTPError(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120927/42b0986c/attachment.html>


More information about the calendarserver-changes mailing list