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 33## 1.0.0-BETA29 (unreleased)
44
55* Fix potential race condition between jobs in ` connect() ` and ` disconnect() ` .
6+ * [ JVM Windows] Fixed PowerSync Extension temporary file deletion error on process shutdown.
67* [ iOS] Fixed issue where automatic driver migrations would fail with the error:
78```
89Sqlite 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 {
5757 }
5858
5959 public companion object {
60- private val powersyncExtension: String = extractLib(" powersync" ).toString()
60+ private val powersyncExtension: String = extractLib(" powersync" )
6161 }
6262}
Original file line number Diff line number Diff line change 11package com.powersync
22
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
74
85private class R
96
10- internal fun extractLib (fileName : String ): Path {
7+ internal fun extractLib (fileName : String ): String {
118 val os = System .getProperty(" os.name" ).lowercase()
129 val (prefix, extension) =
1310 when {
@@ -26,14 +23,12 @@ internal fun extractLib(fileName: String): Path {
2623
2724 val path = " /$prefix${fileName} _$arch .$extension "
2825
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 " ) )
3128
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()
3934}
You can’t perform that action at this time.
0 commit comments