diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ZipUtils.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ZipUtils.kt index 898e594e5b..5e3df8c6c3 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ZipUtils.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ZipUtils.kt @@ -1,6 +1,5 @@ package io.github.typesafegithub.workflows.mavenbinding -import com.intellij.util.io.PagedFileStorage import java.io.BufferedInputStream import java.io.File import java.io.FileInputStream @@ -30,7 +29,6 @@ internal fun OutputStream.createZipFile(contents: Path) = zipFile(file.toFile(), zipOutputStream) } } - zipOutputStream.flush() } /** @@ -61,17 +59,8 @@ private fun zipDirectory( lastAccessTime = FileTime.fromMillis(0) } zos.putNextEntry(zipEntry) - val bis = - BufferedInputStream( - FileInputStream(file), - ) - var bytesRead: Long = 0 - val bytesIn = ByteArray(PagedFileStorage.BUFFER_SIZE) - var read: Int - while ((bis.read(bytesIn).also { read = it }) != -1) { - zos.write(bytesIn, 0, read) - bytesRead += read.toLong() - } + BufferedInputStream(FileInputStream(file)) + .use { it.copyTo(zos) } zos.closeEntry() } } @@ -97,18 +86,7 @@ private fun zipFile( lastAccessTime = FileTime.fromMillis(0) } zos.putNextEntry(zipEntry) - val bis = - BufferedInputStream( - FileInputStream( - file, - ), - ) - var bytesRead: Long = 0 - val bytesIn = ByteArray(PagedFileStorage.BUFFER_SIZE) - var read: Int - while ((bis.read(bytesIn).also { read = it }) != -1) { - zos.write(bytesIn, 0, read) - bytesRead += read.toLong() - } + BufferedInputStream(FileInputStream(file)) + .use { it.copyTo(zos) } zos.closeEntry() }