Skip to content

Commit 17c0edf

Browse files
committed
Ensure absolute paths
1 parent 59527b0 commit 17c0edf

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/kotlin/com/coder/gateway/sdk/CoderCLIManager.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class CoderCLIManager @JvmOverloads constructor(private val deploymentURL: URL,
4141
// necessary character set.
4242
val host = getSafeHost(deploymentURL)
4343
val subdir = if (deploymentURL.port > 0) "${host}-${deploymentURL.port}" else host
44-
localBinaryPath = destinationDir.resolve(subdir).resolve(binaryName)
45-
coderConfigPath = destinationDir.resolve(subdir).resolve("config")
44+
localBinaryPath = destinationDir.resolve(subdir).resolve(binaryName).toAbsolutePath()
45+
coderConfigPath = destinationDir.resolve(subdir).resolve("config").toAbsolutePath()
4646
}
4747

4848
/**
@@ -84,7 +84,7 @@ class CoderCLIManager @JvmOverloads constructor(private val deploymentURL: URL,
8484
val etag = getBinaryETag()
8585
val conn = remoteBinaryUrl.openConnection() as HttpURLConnection
8686
if (etag != null) {
87-
logger.info("Found existing binary at ${localBinaryPath.toAbsolutePath()}; calculated hash as $etag")
87+
logger.info("Found existing binary at $localBinaryPath; calculated hash as $etag")
8888
conn.setRequestProperty("If-None-Match", "\"$etag\"")
8989
}
9090
conn.setRequestProperty("Accept-Encoding", "gzip")
@@ -94,7 +94,7 @@ class CoderCLIManager @JvmOverloads constructor(private val deploymentURL: URL,
9494
logger.info("GET ${conn.responseCode} $remoteBinaryUrl")
9595
when (conn.responseCode) {
9696
HttpURLConnection.HTTP_OK -> {
97-
logger.info("Downloading binary to ${localBinaryPath.toAbsolutePath()}")
97+
logger.info("Downloading binary to $localBinaryPath")
9898
Files.createDirectories(localBinaryPath.parent)
9999
conn.inputStream.use {
100100
Files.copy(
@@ -113,7 +113,7 @@ class CoderCLIManager @JvmOverloads constructor(private val deploymentURL: URL,
113113
}
114114

115115
HttpURLConnection.HTTP_NOT_MODIFIED -> {
116-
logger.info("Using cached binary at ${localBinaryPath.toAbsolutePath()}")
116+
logger.info("Using cached binary at $localBinaryPath")
117117
return false
118118
}
119119
}
@@ -140,7 +140,7 @@ class CoderCLIManager @JvmOverloads constructor(private val deploymentURL: URL,
140140
} catch (e: FileNotFoundException) {
141141
null
142142
} catch (e: Exception) {
143-
logger.warn("Unable to calculate hash for ${localBinaryPath.toAbsolutePath()}", e)
143+
logger.warn("Unable to calculate hash for $localBinaryPath", e)
144144
null
145145
}
146146
}
@@ -156,7 +156,7 @@ class CoderCLIManager @JvmOverloads constructor(private val deploymentURL: URL,
156156
"--token",
157157
token,
158158
"--global-config",
159-
coderConfigPath.toAbsolutePath().toString(),
159+
coderConfigPath.toString(),
160160
)
161161
}
162162

@@ -179,7 +179,7 @@ class CoderCLIManager @JvmOverloads constructor(private val deploymentURL: URL,
179179
"""
180180
Host ${getHostName(deploymentURL, it)}
181181
HostName coder.${it.name}
182-
ProxyCommand "${localBinaryPath.toAbsolutePath()}" --global-config "${coderConfigPath.toAbsolutePath()}" ssh --stdio ${it.name}
182+
ProxyCommand "$localBinaryPath" --global-config "$coderConfigPath" ssh --stdio ${it.name}
183183
ConnectTimeout 0
184184
StrictHostKeyChecking no
185185
UserKnownHostsFile /dev/null

0 commit comments

Comments
 (0)