diff --git a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/gcloud/GoogleCloudApi.kt b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/gcloud/GoogleCloudApi.kt index e0db488..7a538dc 100644 --- a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/gcloud/GoogleCloudApi.kt +++ b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/gcloud/GoogleCloudApi.kt @@ -265,6 +265,11 @@ internal interface BlobVisitor { val fileName: String get() = gcsPath.path.substringAfterLast('/') + /** + * The size of the blob + */ + val size: Long + /** * Opens the input stream to the blob. You must make sure to close it after using it. */ @@ -288,4 +293,6 @@ private class BlobVisitorImpl( override fun toString(): String { return "Blob($gcsPath)" } + + override val size: Long = blob.size } diff --git a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerService.kt b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerService.kt index 8cddce9..292734e 100644 --- a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerService.kt +++ b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerService.kt @@ -238,6 +238,11 @@ interface TestRunnerService { * Creates an [InputStream] for the file. Note that you must close it after using. */ fun openInputStream(): InputStream + + /** + * Size of the file. + */ + val size: Long } /** diff --git a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerServiceImpl.kt b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerServiceImpl.kt index 2e3bed9..0c70f8e 100644 --- a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerServiceImpl.kt +++ b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerServiceImpl.kt @@ -347,6 +347,7 @@ internal class TestRunnerServiceImpl internal constructor( private val blobVisitor: BlobVisitor ) : TestRunnerService.ResultFileResource { override val gcsPath = blobVisitor.gcsPath + override val size = blobVisitor.size override fun openInputStream(): InputStream = blobVisitor.obtainInputStream() override fun toString(): String { return "ResultFile('$gcsPath')" diff --git a/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/fake/FakeGoogleCloudApi.kt b/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/fake/FakeGoogleCloudApi.kt index 201630a..b5a3253 100644 --- a/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/fake/FakeGoogleCloudApi.kt +++ b/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/fake/FakeGoogleCloudApi.kt @@ -57,6 +57,9 @@ internal class FakeGoogleCloudApi( get() = entry.key.path.substringAfter(gcsPath.path).trimStart('/') override val gcsPath: GcsPath get() = entry.key + override val size: Long + get() = artifacts[gcsPath]?.size?.toLong() ?: 0 + override fun obtainInputStream(): InputStream { return entry.value.inputStream() } @@ -71,6 +74,9 @@ internal class FakeGoogleCloudApi( get() = "" override val gcsPath: GcsPath get() = gcsPath + override val size: Long + get() = artifacts[gcsPath]?.size?.toLong() ?: 0 + override fun obtainInputStream(): InputStream { return artifacts[gcsPath]?.inputStream() ?: InputStream.nullInputStream() }