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 3
3
## 1.0.0-BETA31
4
4
5
5
* Added helpers for Attachment syncing.
6
+ * Fix loading native PowerSync extension for Java targets.
6
7
7
8
## 1.0.0-BETA30
8
9
Original file line number Diff line number Diff line change 1
1
package com.powersync
2
2
3
3
import 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
4
8
5
9
private class R
6
10
@@ -21,14 +25,20 @@ internal fun extractLib(fileName: String): String {
21
25
else -> error(" Unsupported architecture: $sysArch " )
22
26
}
23
27
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 )
25
33
26
- val resourceURI =
27
- ( R :: class .java.getResource(path) ? : error( " Resource $path not found " ))
34
+ deleteOnExit()
35
+ }
28
36
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()
34
44
}
You can’t perform that action at this time.
0 commit comments