From e1e6cd269bc255ec1c74fb6bc01d3d14cc5a22bd Mon Sep 17 00:00:00 2001 From: Todd Burnside Date: Tue, 12 Sep 2023 14:20:07 -0300 Subject: [PATCH] Prevent 503's on attachment uploads --- .../main/scala/lucuma/odb/graphql/ObsAttachmentRoutes.scala | 3 +++ .../scala/lucuma/odb/graphql/ProposalAttachmentRoutes.scala | 3 +++ 2 files changed, 6 insertions(+) diff --git a/modules/service/src/main/scala/lucuma/odb/graphql/ObsAttachmentRoutes.scala b/modules/service/src/main/scala/lucuma/odb/graphql/ObsAttachmentRoutes.scala index 6db67763a4..d4ac0010fe 100644 --- a/modules/service/src/main/scala/lucuma/odb/graphql/ObsAttachmentRoutes.scala +++ b/modules/service/src/main/scala/lucuma/odb/graphql/ObsAttachmentRoutes.scala @@ -4,6 +4,7 @@ package lucuma.odb.graphql import cats.effect._ +import cats.effect.implicits._ import cats.effect.std.UUIDGen import cats.implicits._ import eu.timepit.refined.types.string.NonEmptyString @@ -97,6 +98,7 @@ object ObsAttachmentRoutes { s .insertAttachment(user, programId, typeTag, fileName, description, req.body) .flatMap(id => Ok(id.toString)) + .guarantee(req.body.compile.drain) .recoverWith { case EntityLimiter.EntityTooLarge(_) => BadRequest(s"File too large. Limit of $maxUploadMb MB") @@ -113,6 +115,7 @@ object ObsAttachmentRoutes { s .updateAttachment(user, programId, attachmentId, fileName, description, req.body) .flatMap(_ => Ok()) + .guarantee(req.body.compile.drain) .recoverWith { case EntityLimiter.EntityTooLarge(_) => BadRequest(s"File too large. Limit of $maxUploadMb MB") diff --git a/modules/service/src/main/scala/lucuma/odb/graphql/ProposalAttachmentRoutes.scala b/modules/service/src/main/scala/lucuma/odb/graphql/ProposalAttachmentRoutes.scala index 1b014811a7..52fd544ea4 100644 --- a/modules/service/src/main/scala/lucuma/odb/graphql/ProposalAttachmentRoutes.scala +++ b/modules/service/src/main/scala/lucuma/odb/graphql/ProposalAttachmentRoutes.scala @@ -4,6 +4,7 @@ package lucuma.odb.graphql import cats.effect._ +import cats.effect.implicits._ import cats.implicits._ import eu.timepit.refined.types.string.NonEmptyString import lucuma.core.model.Program @@ -95,6 +96,7 @@ object ProposalAttachmentRoutes { s .insertAttachment(user, programId, attachmentType, fileName, description, req.body) .flatMap(_ => Ok()) + .guarantee(req.body.compile.drain) .recoverWith { case EntityLimiter.EntityTooLarge(_) => BadRequest(s"File too large. Limit of $maxUploadMb MB") @@ -111,6 +113,7 @@ object ProposalAttachmentRoutes { s .updateAttachment(user, programId, attachmentType, fileName, description, req.body) .flatMap(_ => Ok()) + .guarantee(req.body.compile.drain) .recoverWith { case EntityLimiter.EntityTooLarge(_) => BadRequest(s"File too large. Limit of $maxUploadMb MB")