File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
core/src/jvmMain/kotlin/com/powersync Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 33## 1.0.0-BETA31
44
55* Added helpers for Attachment syncing.
6+ * Fix loading native PowerSync extension for Java targets.
67
78## 1.0.0-BETA30
89
Original file line number Diff line number Diff line change 11package com.powersync
22
33import java.io.File
4+ import java.nio.file.Files
5+ import java.nio.file.Path
6+ import kotlin.io.path.Path
7+ import kotlin.io.path.absolutePathString
48
59private class R
610
@@ -21,14 +25,20 @@ internal fun extractLib(fileName: String): String {
2125 else -> error(" Unsupported architecture: $sysArch " )
2226 }
2327
24- val path = " /$prefix${fileName} _$arch .$extension "
28+ val path = Files .createTempFile(Path (System .getProperty(" java.io.tmpdir" )), prefix, extension)
29+ val file = path.toFile().apply {
30+ setReadable(true )
31+ setWritable(true )
32+ setExecutable(true )
2533
26- val resourceURI =
27- ( R :: class .java.getResource(path) ? : error( " Resource $path not found " ))
34+ deleteOnExit()
35+ }
2836
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()
37+ val resourcePath = " /$prefix${fileName} _$arch .$extension "
38+
39+ (R ::class .java.getResourceAsStream(resourcePath) ? : error(" Resource $path not found" )).use { input ->
40+ file.outputStream().use { output -> input.copyTo(output) }
41+ }
42+
43+ return path.absolutePathString()
3444}
You can’t perform that action at this time.
0 commit comments