Skip to content

Commit

Permalink
Merge pull request #117 from Malinskiy/feature/streaming_install_resp…
Browse files Browse the repository at this point in the history
…onse

feat(adam): StreamingPackageInstallRequest should return parseable response for errors
  • Loading branch information
Malinskiy authored Aug 14, 2024
2 parents 6cd8361 + e67ab9c commit f206bc9
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StreamingPackageInstallRequest(
private val reinstall: Boolean,
private val extraArgs: List<String> = emptyList(),
val coroutineContext: CoroutineContext = Dispatchers.IO
) : ComplexRequest<Boolean>() {
) : ComplexRequest<StreamingPackageInstallResult>() {
private val transformer = StringResponseTransformer()

override fun validate(): ValidationResponse {
Expand Down Expand Up @@ -110,7 +110,7 @@ class StreamingPackageInstallRequest(
}
}

override suspend fun readElement(socket: Socket): Boolean {
override suspend fun readElement(socket: Socket): StreamingPackageInstallResult {
AsyncFileReader(pkg, coroutineContext = coroutineContext).use { reader ->
reader.start()
reader.copyTo(socket)
Expand All @@ -119,10 +119,14 @@ class StreamingPackageInstallRequest(
withDefaultBuffer {
socket.copyTo(transformer, this)
}
return transformer.transform().startsWith("Success")
val output = transformer.transform()
val success = output.startsWith("Success")
return StreamingPackageInstallResult(output, success)
}

companion object {
val SUPPORTED_EXTENSIONS = setOf("apk", "apex")
}
}

data class StreamingPackageInstallResult(val output: String, val success: Boolean)

0 comments on commit f206bc9

Please sign in to comment.