chetanmeh commented on a change in pull request #3709: Inlined attachments
URL: 
https://github.com/apache/incubator-openwhisk/pull/3709#discussion_r193291365
 
 

 ##########
 File path: 
common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala
 ##########
 @@ -356,13 +356,21 @@ class CouchDbRestStore[DocumentAbstraction <: 
DocumentSerializer](dbProtocol: St
     docStream: Source[ByteString, _],
     oldAttachment: Option[Attached])(implicit transid: TransactionId): 
Future[(DocInfo, Attached)] = {
 
-    val attachmentUri = Uri.from(scheme = attachmentScheme, path = 
UUID().asString)
-    val attached = Attached(attachmentUri.toString(), contentType)
-    val updatedDoc = update(d, attached)
-
     for {
-      i1 <- put(updatedDoc)
-      i2 <- attach(i1, attachmentUri.path.toString(), attached.attachmentType, 
docStream)
+      (bytes, tailSource) <- inlineAndTail(docStream)
+      uri <- Future.successful(uriOf(bytes, UUID().asString))
+      attached <- {
+        val a = if (isInlined(uri)) {
+          Attached(uri.toString(), contentType, Some(bytes.size), 
Some(digest(bytes)))
 
 Review comment:
   Good point. Updated now

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to