[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
This commit is contained in:
Nikolay Chashnikov
2021-01-27 08:06:56 +00:00
committed by intellij-monorepo-bot
parent 275060fd76
commit b6c6b45116
@@ -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 {