Skip to content

Commit

Permalink
fix(android): use graph-uuid in call, update capacitor-file-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Sep 23, 2022
1 parent dd91207 commit d1c7328
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/assets/capacitor.plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
{
"pkg": "@logseq/capacitor-file-sync",
"classpath": "com.logseq.app.FileSyncPlugin"
"classpath": "com.logseq.app.filesync.FileSyncPlugin"
},
{
"pkg": "capacitor-voice-recorder",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"@capacitor/status-bar": "^4.0.0",
"@excalidraw/excalidraw": "0.10.0",
"@kanru/rage-wasm": "0.2.1",
"@logseq/capacitor-file-sync": "0.0.6",
"@logseq/capacitor-file-sync": "0.0.10",
"@logseq/react-tweet-embed": "1.3.1-1",
"@sentry/react": "^6.18.2",
"@sentry/tracing": "^6.18.2",
Expand Down
33 changes: 20 additions & 13 deletions src/main/frontend/fs/sync.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -820,13 +820,15 @@
(set! graph-uuid' graph-uuid)
(set! private-key secret-key)
(set! public-key' public-key)
(p->c (.setEnv mobile-util/file-sync (clj->js {:env (if prod? "prod" "dev")
(p->c (.setEnv mobile-util/file-sync (clj->js {:graphUUID graph-uuid
:env (if prod? "prod" "dev")
:secretKey secret-key
:publicKey public-key}))))

(<get-local-all-files-meta [_ _graph-uuid base-path]
(<get-local-all-files-meta [_ graph-uuid base-path]
(go
(let [r (<! (p->c (.getLocalAllFilesMeta mobile-util/file-sync (clj->js {:basePath base-path}))))]
(let [r (<! (p->c (.getLocalAllFilesMeta mobile-util/file-sync (clj->js {:graphUUID graph-uuid
:basePath base-path}))))]
(if (instance? ExceptionInfo r)
r
(->> (.-result r)
Expand All @@ -836,10 +838,11 @@
(get metadata "encryptedFname") (get metadata "mtime") false nil)))
set)))))

(<get-local-files-meta [_ _graph-uuid base-path filepaths]
(<get-local-files-meta [_ graph-uuid base-path filepaths]
(go
(let [r (<! (p->c (.getLocalFilesMeta mobile-util/file-sync
(clj->js {:basePath base-path
(clj->js {:graphUUID graph-uuid
:basePath base-path
:filePaths filepaths}))))]
(assert (not (instance? ExceptionInfo r)) "get-local-files-meta shouldn't return exception")
(->> (.-result r)
Expand All @@ -849,9 +852,10 @@
(get metadata "encryptedFname") (get metadata "mtime") false nil)))
set))))

(<rename-local-file [_ _graph-uuid base-path from to]
(<rename-local-file [_ graph-uuid base-path from to]
(p->c (.renameLocalFile mobile-util/file-sync
(clj->js {:basePath base-path
(clj->js {:graphUUID graph-uuid
:basePath base-path
:from from
:to to}))))

Expand All @@ -874,10 +878,11 @@
:token token})))))]
r)))

(<delete-local-files [_ _graph-uuid base-path filepaths]
(<delete-local-files [_ graph-uuid base-path filepaths]
(go
(let [r (<! (<retry-rsapi #(p->c (.deleteLocalFiles mobile-util/file-sync
(clj->js {:basePath base-path
(clj->js {:graphUUID graph-uuid
:basePath base-path
:filePaths filepaths})))))]
r)))

Expand Down Expand Up @@ -907,16 +912,18 @@
r
(get (js->clj r) "txid")))))

(<encrypt-fnames [_ _graph-uuid fnames]
(<encrypt-fnames [_ graph-uuid fnames]
(go
(let [r (<! (p->c (.encryptFnames mobile-util/file-sync
(clj->js {:filePaths fnames}))))]
(clj->js {:graphUUID graph-uuid
:filePaths fnames}))))]
(if (instance? ExceptionInfo r)
(.-cause r)
(get (js->clj r) "value")))))
(<decrypt-fnames [_ _graph-uuid fnames]
(<decrypt-fnames [_ graph-uuid fnames]
(go (let [r (<! (p->c (.decryptFnames mobile-util/file-sync
(clj->js {:filePaths fnames}))))]
(clj->js {:graphUUID graph-uuid
:filePaths fnames}))))]
(if (instance? ExceptionInfo r)
(ex-info "decrypt-failed" {:fnames fnames} (ex-cause r))
(get (js->clj r) "value"))))))
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,10 @@
resolved "https://registry.yarnpkg.com/@kanru/rage-wasm/-/rage-wasm-0.2.1.tgz#dd8fdd3133992c42bf68c0086d8cad40a13bc329"
integrity sha512-sYi4F2mL6Mpcz7zbS4myasw11xLBEbgZkDMRVg9jNxTKt6Ct/LT7/vCHDmEzAFcPcPqixD5De6Ql3bJijAX0/w==

"@logseq/[email protected].6":
version "0.0.6"
resolved "https://registry.yarnpkg.com/@logseq/capacitor-file-sync/-/capacitor-file-sync-0.0.6.tgz#e738ec08c1249ad96560c5f5090a60f4f49d679a"
integrity sha512-gnSAm2x9jNAtlQP4r8S5P2a7vRYZkGDIh6wX1/UgldDHPaY//+SWYvtFQQeDEJ1rLU/S+UYnPndlQdMDpu6mqA==
"@logseq/[email protected].10":
version "0.0.10"
resolved "https://registry.yarnpkg.com/@logseq/capacitor-file-sync/-/capacitor-file-sync-0.0.10.tgz#36575b369a4fff83e71b282c19cc948d60309809"
integrity sha512-O4bCHLym7+DnqCoO57D1Ii6ec6tcZBjp8SzFEYCKE9mvHsX5aFmCA61XUHgNEFovocQ3gBMJvi6GKSJBcGwT3Q==

"@logseq/[email protected]":
version "1.3.1-1"
Expand Down

0 comments on commit d1c7328

Please sign in to comment.