Skip to content

Commit aa6253d

Browse files
authored
Update google cloud api to return sizes for files in gcs. (#85)
1 parent 7b847e1 commit aa6253d

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

Diff for: AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/gcloud/GoogleCloudApi.kt

+7
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ internal interface BlobVisitor {
265265
val fileName: String
266266
get() = gcsPath.path.substringAfterLast('/')
267267

268+
/**
269+
* The size of the blob
270+
*/
271+
val size: Long
272+
268273
/**
269274
* Opens the input stream to the blob. You must make sure to close it after using it.
270275
*/
@@ -288,4 +293,6 @@ private class BlobVisitorImpl(
288293
override fun toString(): String {
289294
return "Blob($gcsPath)"
290295
}
296+
297+
override val size: Long = blob.size
291298
}

Diff for: AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerService.kt

+5
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ interface TestRunnerService {
238238
* Creates an [InputStream] for the file. Note that you must close it after using.
239239
*/
240240
fun openInputStream(): InputStream
241+
242+
/**
243+
* Size of the file.
244+
*/
245+
val size: Long
241246
}
242247

243248
/**

Diff for: AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerServiceImpl.kt

+1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ internal class TestRunnerServiceImpl internal constructor(
347347
private val blobVisitor: BlobVisitor
348348
) : TestRunnerService.ResultFileResource {
349349
override val gcsPath = blobVisitor.gcsPath
350+
override val size = blobVisitor.size
350351
override fun openInputStream(): InputStream = blobVisitor.obtainInputStream()
351352
override fun toString(): String {
352353
return "ResultFile('$gcsPath')"

Diff for: AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/fake/FakeGoogleCloudApi.kt

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ internal class FakeGoogleCloudApi(
5757
get() = entry.key.path.substringAfter(gcsPath.path).trimStart('/')
5858
override val gcsPath: GcsPath
5959
get() = entry.key
60+
override val size: Long
61+
get() = artifacts[gcsPath]?.size?.toLong() ?: 0
62+
6063
override fun obtainInputStream(): InputStream {
6164
return entry.value.inputStream()
6265
}
@@ -71,6 +74,9 @@ internal class FakeGoogleCloudApi(
7174
get() = ""
7275
override val gcsPath: GcsPath
7376
get() = gcsPath
77+
override val size: Long
78+
get() = artifacts[gcsPath]?.size?.toLong() ?: 0
79+
7480
override fun obtainInputStream(): InputStream {
7581
return artifacts[gcsPath]?.inputStream() ?: InputStream.nullInputStream()
7682
}

0 commit comments

Comments
 (0)