mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: sqlite import
This commit is contained in:
@@ -517,10 +517,21 @@ export function base64ToUint8Array (base64String) {
|
||||
|
||||
export function uint8ArrayToBase64 (uint8Array) {
|
||||
try {
|
||||
let bytes = null
|
||||
if (uint8Array instanceof Uint8Array) {
|
||||
bytes = uint8Array
|
||||
} else if (ArrayBuffer.isView(uint8Array)) {
|
||||
bytes = new Uint8Array(uint8Array.buffer, uint8Array.byteOffset, uint8Array.byteLength)
|
||||
} else if (uint8Array instanceof ArrayBuffer) {
|
||||
bytes = new Uint8Array(uint8Array)
|
||||
} else {
|
||||
throw new TypeError('Expected Uint8Array, TypedArray, or ArrayBuffer')
|
||||
}
|
||||
|
||||
let binary = ''
|
||||
const len = uint8Array.byteLength
|
||||
const len = bytes.byteLength
|
||||
for (let i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode(uint8Array[i])
|
||||
binary += String.fromCharCode(bytes[i])
|
||||
}
|
||||
return btoa(binary)
|
||||
} catch (e) {
|
||||
|
||||
@@ -918,9 +918,9 @@
|
||||
(def-thread-api :thread-api/import-db-base64
|
||||
[repo base64]
|
||||
(when-not (string/blank? repo)
|
||||
(p/let [pool (<get-opfs-pool repo)
|
||||
data (worker-util/base64string-to-unit8array base64)
|
||||
(p/let [data (worker-util/base64string-to-unit8array base64)
|
||||
_ (close-db! repo)
|
||||
pool (<get-opfs-pool repo)
|
||||
_ (<import-db pool data)
|
||||
_ (start-db! repo {:import-type :sqlite-db})]
|
||||
nil)))
|
||||
|
||||
Reference in New Issue
Block a user