File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
src/main/kotlin/com/coder/gateway/sdk Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.coder.gateway.sdk
3
3
import com.intellij.openapi.diagnostic.Logger
4
4
import java.io.InputStream
5
5
import java.net.URL
6
+ import java.nio.file.FileVisitOption
6
7
import java.nio.file.Files
7
8
import java.nio.file.Path
8
9
import java.nio.file.Paths
@@ -67,9 +68,14 @@ class CoderCLIManager(url: URL, buildVersion: String) {
67
68
}
68
69
69
70
fun removeOldCli () {
70
- Files .walk(Path .of(tmpDir)).sorted().map { it.toFile() }.filter { it.name.contains(cliNamePrefix) && ! it.name.contains(cliFileName) }.forEach {
71
- logger.info(" Removing $it because it is an old coder cli" )
72
- it.delete()
71
+ val tmpPath = Path .of(tmpDir)
72
+ if (Files .isReadable(tmpPath)) {
73
+ Files .walk(tmpPath, 1 ).use {
74
+ it.sorted().map { pt -> pt.toFile() }.filter { fl -> fl.name.contains(cliNamePrefix) && ! fl.name.contains(cliFileName) }.forEach { fl ->
75
+ logger.info(" Removing $fl because it is an old coder cli" )
76
+ fl.delete()
77
+ }
78
+ }
73
79
}
74
80
}
75
81
You can’t perform that action at this time.
0 commit comments