@@ -11,6 +11,9 @@ import java.net.http.HttpResponse.BodyHandlers
11
11
import java.nio.channels.Channels
12
12
import java.nio.channels.FileChannel
13
13
import java.nio.file.Path
14
+ import java.nio.file.StandardOpenOption.CREATE
15
+ import java.nio.file.StandardOpenOption.TRUNCATE_EXISTING
16
+ import java.nio.file.StandardOpenOption.WRITE
14
17
import java.nio.file.attribute.FileTime
15
18
import java.time.Duration
16
19
import java.time.Instant
@@ -24,7 +27,6 @@ import kotlin.io.path.deleteIfExists
24
27
import kotlin.io.path.exists
25
28
import kotlin.io.path.getLastModifiedTime
26
29
import kotlin.io.path.name
27
- import kotlin.io.path.outputStream
28
30
import kotlin.io.path.readText
29
31
import kotlin.io.path.setLastModifiedTime
30
32
import kotlin.io.path.writeText
@@ -128,7 +130,7 @@ abstract class DownloadService : BuildService<BuildServiceParameters.None> {
128
130
129
131
downloadCallback()
130
132
131
- FileChannel .open(target).use { output ->
133
+ FileChannel .open(target, CREATE , TRUNCATE_EXISTING , WRITE ).use { output ->
132
134
Channels .newChannel(response.body()).use { input ->
133
135
output.transferFrom(input, 0 , Long .MAX_VALUE )
134
136
}
0 commit comments