diff options
author | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2016-06-01 22:50:17 -0400 |
---|---|---|
committer | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2016-06-01 22:50:17 -0400 |
commit | 48e2c38cf17e9dc5489e3ce3e4885a6db1f418f7 (patch) | |
tree | f11541147ad1c176ac60bef26365a9a571696406 /stage2/Lib.scala | |
parent | ca412e26d70a6615153136019b7966acb9939446 (diff) | |
parent | dd714d751364878c43718e87268347f5645f55d3 (diff) | |
download | cbt-48e2c38cf17e9dc5489e3ce3e4885a6db1f418f7.tar.gz cbt-48e2c38cf17e9dc5489e3ce3e4885a6db1f418f7.tar.bz2 cbt-48e2c38cf17e9dc5489e3ce3e4885a6db1f418f7.zip |
Merge pull request #135 from cvogt/chris
Chris
Diffstat (limited to 'stage2/Lib.scala')
-rw-r--r-- | stage2/Lib.scala | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala index acd62c8..ac7b45c 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -371,35 +371,37 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ def publishUnsigned( sourceFiles: Seq[File], artifacts: Seq[File], url: URL, credentials: String ): Unit = { if(sourceFiles.nonEmpty){ - val files = artifacts.map(nameAndContents) - uploadAll(url, files, credentials) + publish( artifacts, url, credentials ) } } def publishSigned( sourceFiles: Seq[File], artifacts: Seq[File], url: URL, credentials: String ): Unit = { // TODO: make concurrency configurable here if(sourceFiles.nonEmpty){ - val files = (artifacts ++ artifacts.map(sign)).map(nameAndContents) - lazy val checksums = files.flatMap{ - case (name, content) => Seq( - name++".md5" -> md5(content).toArray.map(_.toByte), - name++".sha1" -> sha1(content).toArray.map(_.toByte) - ) - } - val all = (files ++ checksums) - uploadAll(url, all, credentials) + publish( artifacts ++ artifacts.map(sign), url, credentials ) } } + private def publish(artifacts: Seq[File], url: URL, credentials: String): Unit = { + val files = artifacts.map(nameAndContents) + lazy val checksums = files.flatMap{ + case (name, content) => Seq( + name++".md5" -> md5(content).toArray.map(_.toByte), + name++".sha1" -> sha1(content).toArray.map(_.toByte) + ) + } + val all = (files ++ checksums) + uploadAll(url, all, credentials) + } def uploadAll(url: URL, nameAndContents: Seq[(String, Array[Byte])], credentials: String ): Unit = - nameAndContents.map{ case(name, content) => upload(name, content, url, credentials: String ) } + nameAndContents.map{ case(name, content) => upload(name, content, url, credentials ) } def upload(fileName: String, fileContents: Array[Byte], baseUrl: URL, credentials: String): Unit = { import java.net._ import java.io._ - logger.task("uploading "++fileName) val url = baseUrl ++ fileName + System.err.println(blue("uploading ") ++ url.toString) val httpCon = url.openConnection.asInstanceOf[HttpURLConnection] httpCon.setDoOutput(true) httpCon.setRequestMethod("PUT") |