From 47dcad5a3d50f9e603ce6fd008e01661b18a3e4f Mon Sep 17 00:00:00 2001 From: Jakub Chrzanowski Date: Tue, 8 Mar 2022 10:50:47 +0100 Subject: [PATCH] android_studio_releases.main.kts: bump version only if content changed --- .../scripts/android_studio_releases.main.kts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/scripts/android_studio_releases.main.kts b/.github/scripts/android_studio_releases.main.kts index 93b5c35fe..abe146ff7 100755 --- a/.github/scripts/android_studio_releases.main.kts +++ b/.github/scripts/android_studio_releases.main.kts @@ -84,7 +84,13 @@ frameUrl.fetch { content -> Item(name, build, version, channel, platformBuild.toString(), platformVersion.toString(), date) } }.let { - Content(current.version + 1, it) + val version = with (current) { + when (items.hashCode() != it.hashCode()) { + true -> version + 1 + false -> version + } + } + Content(version, it) }.also { Persister().write(it, contentFile) }.also { (_, items) -> @@ -130,10 +136,11 @@ fun String.download(block: (File) -> T) = URL(this).openStream().use { input File.createTempFile("android-studio", ".zip").also(File::deleteOnExit).let { tempFile -> FileOutputStream(tempFile).use { outputStream -> println(" Downloading $this to $tempFile") - val data = ByteArray(1024) - var count: Int - while (bis.read(data, 0, data.size).also { count = it } != -1) { - outputStream.write(data, 0, count) + ByteArray(1024).let { data -> + var count: Int + while (bis.read(data, 0, data.size).also { count = it } != -1) { + outputStream.write(data, 0, count) + } } } block(tempFile)