From b6c6b45116766c693f40ef73dc9bd74c8de9bb0d Mon Sep 17 00:00:00 2001 From: Nikolay Chashnikov Date: Wed, 27 Jan 2021 00:45:01 +0300 Subject: [PATCH] [build scripts] fix heuristic used to determine 'isDirectory' flag by file name (IDEA-259708) dist.all/bin, *.for_twisted and .github paths refer to directories, not files. And a workaround to catch IOException doesn't work on Windows because attempt to read content of a directory results in AccessDeniedException without "Is a directory" text. GitOrigin-RevId: 5be74d285a78f001a2196bc9866583cda5555422 --- build/tasks/src/org/jetbrains/intellij/build/io/zip.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/tasks/src/org/jetbrains/intellij/build/io/zip.kt b/build/tasks/src/org/jetbrains/intellij/build/io/zip.kt index f107df354b0f..781bc83cce04 100644 --- a/build/tasks/src/org/jetbrains/intellij/build/io/zip.kt +++ b/build/tasks/src/org/jetbrains/intellij/build/io/zip.kt @@ -144,16 +144,16 @@ private fun compressDir(startDir: Path, archiver: ZipArchiver, logger: System.Lo tempList.sort() for (file in tempList) { - val path = file.toString() + val fileName = file.fileName.toString() val isFile: Boolean - val lastDot = path.lastIndexOf('.') + val lastDot = fileName.lastIndexOf('.') if (lastDot == -1) { - isFile = path.endsWith("LICENSE") + isFile = fileName.endsWith("LICENSE") } else { // foo-1.2.3 is a directory - isFile = lastDot < path.length && path[lastDot + 1] >= 'A' + isFile = lastDot < fileName.length && fileName[lastDot + 1] >= 'A' && !fileName.endsWith("for_twisted") && fileName != ".github" } if (isFile) { @@ -162,7 +162,7 @@ private fun compressDir(startDir: Path, archiver: ZipArchiver, logger: System.Lo } catch (e: IOException) { if (e.message == "Is a directory") { - logger?.warn("$path expected to be a file, but it is a directory, please rename it") + logger?.warn("$file expected to be a file, but it is a directory, please rename it") dirCandidates.add(file) } else {