Skip to content

Commit

Permalink
Update comments re existing packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanjr committed Jun 19, 2020
1 parent b9abb42 commit 965e6a0
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Server(triggerDao: RunningTriggerDao) {
val compiledPackages: MutableCompiledPackages = ConcurrentCompiledPackages()

// Add a dar to compiledPackages (in memory) and to persistent storage if using it.
// TODO(RJR): Figure out what to do with packages that already exist in `compiledPackages`.
private def addDar(encodedDar: Dar[(PackageId, DamlLf.ArchivePayload)]): Either[String, Unit] = {
// Decode the dar for the in-memory store.
val dar = encodedDar.map((Decode.readArchivePayload _).tupled)
Expand All @@ -98,10 +99,11 @@ class Server(triggerDao: RunningTriggerDao) {
case _ => throw new RuntimeException(s"Unexpected engine result $r")
}

// TODO(RJR): Check if the package is already stored and return an error if so.
go(compiledPackages.addPackage(pkgId, pkg))
}

// TODO(RJR): Only attempt to write packages that aren't already uploaded.
// Otherwise the transaction will fail due to a primary key conflict.
triggerDao.persistPackages(encodedDar)
}

Expand Down Expand Up @@ -290,9 +292,6 @@ object Server {
try {
server.addDar(dar) match {
case Left(err) =>
// TODO(RJR): We should analyze this error to give the appropriate
// error code and message. For example if `addDar` failed due to the
// dar already existing then the request was to blame.
complete(errorResponse(StatusCodes.InternalServerError, err))
case Right(()) =>
val mainPackageId =
Expand Down

0 comments on commit 965e6a0

Please sign in to comment.