11package io.github.typesafegithub.workflows.mavenbinding
22
3- import com.intellij.util.io.PagedFileStorage
43import java.io.BufferedInputStream
54import java.io.File
65import java.io.FileInputStream
@@ -30,7 +29,6 @@ internal fun OutputStream.createZipFile(contents: Path) =
3029 zipFile(file.toFile(), zipOutputStream)
3130 }
3231 }
33- zipOutputStream.flush()
3432 }
3533
3634/* *
@@ -61,17 +59,8 @@ private fun zipDirectory(
6159 lastAccessTime = FileTime .fromMillis(0 )
6260 }
6361 zos.putNextEntry(zipEntry)
64- val bis =
65- BufferedInputStream (
66- FileInputStream (file),
67- )
68- var bytesRead: Long = 0
69- val bytesIn = ByteArray (PagedFileStorage .BUFFER_SIZE )
70- var read: Int
71- while ((bis.read(bytesIn).also { read = it }) != - 1 ) {
72- zos.write(bytesIn, 0 , read)
73- bytesRead + = read.toLong()
74- }
62+ BufferedInputStream (FileInputStream (file))
63+ .use { it.copyTo(zos) }
7564 zos.closeEntry()
7665 }
7766}
@@ -97,18 +86,7 @@ private fun zipFile(
9786 lastAccessTime = FileTime .fromMillis(0 )
9887 }
9988 zos.putNextEntry(zipEntry)
100- val bis =
101- BufferedInputStream (
102- FileInputStream (
103- file,
104- ),
105- )
106- var bytesRead: Long = 0
107- val bytesIn = ByteArray (PagedFileStorage .BUFFER_SIZE )
108- var read: Int
109- while ((bis.read(bytesIn).also { read = it }) != - 1 ) {
110- zos.write(bytesIn, 0 , read)
111- bytesRead + = read.toLong()
112- }
89+ BufferedInputStream (FileInputStream (file))
90+ .use { it.copyTo(zos) }
11391 zos.closeEntry()
11492}
0 commit comments