From 507c744ede971205641d140fd7ed290ab2616c30 Mon Sep 17 00:00:00 2001 From: Ahoo Wang Date: Tue, 23 May 2023 10:59:24 +0800 Subject: [PATCH] fix: import config (#173) --- .../kotlin/me/ahoo/cosky/rest/util/Zips.kt | 19 ++++++++++++++++++- gradle.properties | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cosky-rest-api/src/main/kotlin/me/ahoo/cosky/rest/util/Zips.kt b/cosky-rest-api/src/main/kotlin/me/ahoo/cosky/rest/util/Zips.kt index fc76abad..57e0cc09 100644 --- a/cosky-rest-api/src/main/kotlin/me/ahoo/cosky/rest/util/Zips.kt +++ b/cosky-rest-api/src/main/kotlin/me/ahoo/cosky/rest/util/Zips.kt @@ -16,9 +16,12 @@ import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.InputStream import java.nio.charset.StandardCharsets +import java.nio.file.Paths import java.util.zip.ZipEntry import java.util.zip.ZipInputStream import java.util.zip.ZipOutputStream +import kotlin.io.path.isHidden +import kotlin.io.path.name /** * Zip tool. @@ -45,6 +48,7 @@ object Zips { return unzip(ByteArrayInputStream(zipSource)) } + @Suppress("LoopWithTooManyJumpStatements") @JvmStatic fun unzip(zipSource: InputStream): List { val items: MutableList = ArrayList() @@ -52,15 +56,22 @@ object Zips { var entry: ZipEntry? = zipInputStream.nextEntry while (entry != null) { if (entry.isDirectory) { + entry = zipInputStream.nextEntry continue } + val path = Paths.get(entry.name) + if (path.isHidden()) { + entry = zipInputStream.nextEntry + continue + } + ByteArrayOutputStream().use { itemOutputStream -> val buffer = ByteArray(1024) var offset: Int while (zipInputStream.read(buffer).also { offset = it } != -1) { itemOutputStream.write(buffer, 0, offset) } - val entryName = entry!!.name + val entryName = path.fileName.name items.add(ZipItem.of(entryName, itemOutputStream.toString("UTF-8"))) } entry = zipInputStream.nextEntry @@ -77,5 +88,11 @@ object Zips { return ZipItem(name, data) } } + + override fun toString(): String { + return "ZipItem(name='$name')" + } + + } } diff --git a/gradle.properties b/gradle.properties index ae3bb72a..6307789a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ # limitations under the License. # group=me.ahoo.cosky -version=3.3.13 +version=3.3.14 description=High-performance, low-cost microservice governance platform. Service Discovery and Configuration Service. website=https://github.com/Ahoo-Wang/cosky issues=https://github.com/Ahoo-Wang/cosky/issues