File tree Expand file tree Collapse file tree 3 files changed +11
-15
lines changed
core/src/jvmMain/kotlin/com/powersync Expand file tree Collapse file tree 3 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 3
3
## 1.0.0-BETA29 (unreleased)
4
4
5
5
* Fix potential race condition between jobs in ` connect() ` and ` disconnect() ` .
6
+ * [ JVM Windows] Fixed PowerSync Extension temporary file deletion error on process shutdown.
6
7
* [ iOS] Fixed issue where automatic driver migrations would fail with the error:
7
8
```
8
9
Sqlite operation failure database is locked attempted to run migration and failed. closing connection
Original file line number Diff line number Diff line change @@ -57,6 +57,6 @@ public actual class DatabaseDriverFactory {
57
57
}
58
58
59
59
public companion object {
60
- private val powersyncExtension: String = extractLib(" powersync" ).toString()
60
+ private val powersyncExtension: String = extractLib(" powersync" )
61
61
}
62
62
}
Original file line number Diff line number Diff line change 1
1
package com.powersync
2
2
3
- import java.nio.file.Path
4
- import kotlin.io.path.createTempFile
5
- import kotlin.io.path.deleteIfExists
6
- import kotlin.io.path.outputStream
3
+ import java.io.File
7
4
8
5
private class R
9
6
10
- internal fun extractLib (fileName : String ): Path {
7
+ internal fun extractLib (fileName : String ): String {
11
8
val os = System .getProperty(" os.name" ).lowercase()
12
9
val (prefix, extension) =
13
10
when {
@@ -26,14 +23,12 @@ internal fun extractLib(fileName: String): Path {
26
23
27
24
val path = " /$prefix${fileName} _$arch .$extension "
28
25
29
- val tmpPath = createTempFile( " $prefix$fileName " , " . $extension " )
30
- Runtime .getRuntime().addShutdownHook( Thread { tmpPath.deleteIfExists() } )
26
+ val resourceURI =
27
+ ( R :: class .java.getResource(path) ? : error( " Resource $path not found " ) )
31
28
32
- (R ::class .java.getResourceAsStream(path) ? : error(" Resource $path not found" )).use { input ->
33
- tmpPath.outputStream().use { output ->
34
- input.copyTo(output)
35
- }
36
- }
37
-
38
- return tmpPath
29
+ // Wrapping the above in a File handle resolves the URI to a path usable by SQLite.
30
+ // This is particularly relevant on Windows.
31
+ // On Windows [resourceURI.path] starts with a `/`, e.g. `/c:/...`. SQLite does not load this path correctly.
32
+ // The wrapping here transforms the path to `c:/...` which does load correctly.
33
+ return File (resourceURI.path).path.toString()
39
34
}
You can’t perform that action at this time.
0 commit comments