mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 11:26:26 +00:00
deprecate: on-disk encryption
Why? 1. there're still a lot issues on it and there's no resource to maintain and develop it considering we need to support it on all the platforms. 2. it creates more bugs with Logseq Sync.
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
[goog.string :as gstring]
|
||||
[frontend.config :as config]
|
||||
[frontend.db :as db]
|
||||
[frontend.encrypt :as encrypt]
|
||||
[frontend.fs.protocol :as protocol]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[frontend.state :as state]
|
||||
@@ -105,10 +104,7 @@
|
||||
(defn- contents-matched?
|
||||
[disk-content db-content]
|
||||
(when (and (string? disk-content) (string? db-content))
|
||||
(if (encrypt/encrypted-db? (state/get-current-repo))
|
||||
(p/let [decrypted-content (encrypt/decrypt disk-content)]
|
||||
(= (string/trim decrypted-content) (string/trim db-content)))
|
||||
(p/resolved (= (string/trim disk-content) (string/trim db-content))))))
|
||||
(p/resolved (= (string/trim disk-content) (string/trim db-content)))))
|
||||
|
||||
(def backup-dir "logseq/bak")
|
||||
(def version-file-dir "logseq/version-files/local")
|
||||
@@ -195,7 +191,7 @@
|
||||
(not contents-matched?)
|
||||
(not (contains? #{"excalidraw" "edn" "css"} ext))
|
||||
(not (string/includes? path "/.recycle/")))
|
||||
(p/let [disk-content (encrypt/decrypt disk-content)]
|
||||
(p/let [disk-content disk-content]
|
||||
(state/pub-event! [:file/not-matched-from-disk path disk-content content]))
|
||||
|
||||
:else
|
||||
@@ -206,9 +202,7 @@
|
||||
(when-not contents-matched?
|
||||
(backup-file repo-dir :backup-dir path disk-content))
|
||||
(db/set-file-last-modified-at! repo path mtime)
|
||||
(p/let [content (if (encrypt/encrypted-db? (state/get-current-repo))
|
||||
(encrypt/decrypt content)
|
||||
content)]
|
||||
(p/let [content content]
|
||||
(db/set-file-content! repo path content))
|
||||
(when ok-handler
|
||||
(ok-handler repo path result))
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
[frontend.config :as config]
|
||||
[frontend.state :as state]
|
||||
[frontend.handler.notification :as notification]
|
||||
["/frontend/utils" :as utils]
|
||||
[frontend.encrypt :as encrypt]))
|
||||
["/frontend/utils" :as utils]))
|
||||
|
||||
;; We need to cache the file handles in the memory so that
|
||||
;; the browser will not keep asking permissions.
|
||||
@@ -58,10 +57,7 @@
|
||||
(defn- contents-matched?
|
||||
[disk-content db-content]
|
||||
(when (and (string? disk-content) (string? db-content))
|
||||
(if (encrypt/encrypted-db? (state/get-current-repo))
|
||||
(p/let [decrypted-content (encrypt/decrypt disk-content)]
|
||||
(= (string/trim decrypted-content) (string/trim db-content)))
|
||||
(p/resolved (= (string/trim disk-content) (string/trim db-content))))))
|
||||
(p/resolved (= (string/trim disk-content) (string/trim db-content)))))
|
||||
|
||||
(defrecord ^:large-vars/cleanup-todo Nfs []
|
||||
protocol/Fs
|
||||
@@ -173,16 +169,12 @@
|
||||
(not contents-matched?)
|
||||
(not (contains? #{"excalidraw" "edn" "css"} ext))
|
||||
(not (string/includes? path "/.recycle/")))
|
||||
(p/let [local-content (encrypt/decrypt local-content)]
|
||||
(state/pub-event! [:file/not-matched-from-disk path local-content content]))
|
||||
(state/pub-event! [:file/not-matched-from-disk path local-content content])
|
||||
(p/let [_ (verify-permission repo file-handle true)
|
||||
_ (utils/writeFile file-handle content)
|
||||
file (.getFile file-handle)]
|
||||
(when file
|
||||
(p/let [content (if (encrypt/encrypted-db? (state/get-current-repo))
|
||||
(encrypt/decrypt content)
|
||||
content)]
|
||||
(db/set-file-content! repo path content))
|
||||
(db/set-file-content! repo path content)
|
||||
(nfs-saved-handler repo path file))))))
|
||||
(p/catch (fn [e]
|
||||
(js/console.error e))))
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
[frontend.util :as util]
|
||||
[goog.object :as gobj]
|
||||
[lambdaisland.glogi :as log]
|
||||
[promesa.core :as p]
|
||||
[frontend.encrypt :as encrypt]))
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn concat-path
|
||||
[dir path]
|
||||
@@ -29,10 +28,7 @@
|
||||
(defn- contents-matched?
|
||||
[disk-content db-content]
|
||||
(when (and (string? disk-content) (string? db-content))
|
||||
(if (encrypt/encrypted-db? (state/get-current-repo))
|
||||
(p/let [decrypted-content (encrypt/decrypt disk-content)]
|
||||
(= (string/trim decrypted-content) (string/trim db-content)))
|
||||
(p/resolved (= (string/trim disk-content) (string/trim db-content))))))
|
||||
(p/resolved (= (string/trim disk-content) (string/trim db-content)))))
|
||||
|
||||
(defn- write-file-impl!
|
||||
[this repo dir path content {:keys [ok-handler error-handler old-content skip-compare?]} stat]
|
||||
@@ -61,8 +57,7 @@
|
||||
(not contents-matched?)
|
||||
(not (contains? #{"excalidraw" "edn" "css"} ext))
|
||||
(not (string/includes? path "/.recycle/")))
|
||||
(p/let [disk-content (encrypt/decrypt disk-content)]
|
||||
(state/pub-event! [:file/not-matched-from-disk path disk-content content]))
|
||||
(state/pub-event! [:file/not-matched-from-disk path disk-content content])
|
||||
|
||||
:else
|
||||
(->
|
||||
@@ -71,10 +66,7 @@
|
||||
(when-not contents-matched?
|
||||
(ipc/ipc "backupDbFile" (config/get-local-dir repo) path disk-content content))
|
||||
(db/set-file-last-modified-at! repo path mtime)
|
||||
(p/let [content (if (encrypt/encrypted-db? (state/get-current-repo))
|
||||
(encrypt/decrypt content)
|
||||
content)]
|
||||
(db/set-file-content! repo path content))
|
||||
(db/set-file-content! repo path content)
|
||||
(when ok-handler
|
||||
(ok-handler repo path result))
|
||||
result)
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
[lambdaisland.glogi :as log]
|
||||
[promesa.core :as p]
|
||||
[frontend.state :as state]
|
||||
[frontend.encrypt :as encrypt]
|
||||
[frontend.fs :as fs]))
|
||||
|
||||
;; all IPC paths must be normalized! (via gp-util/path-normalize)
|
||||
@@ -56,9 +55,7 @@
|
||||
pages-metadata-path (config/get-pages-metadata-path)
|
||||
{:keys [mtime]} stat
|
||||
db-content (or (db/get-file repo path) "")]
|
||||
(when (and (or content (contains? #{"unlink" "unlinkDir" "addDir"} type))
|
||||
(not (encrypt/content-encrypted? content))
|
||||
(not (:encryption/graph-parsing? @state/state)))
|
||||
(when (or content (contains? #{"unlink" "unlinkDir" "addDir"} type))
|
||||
(cond
|
||||
(and (= "unlinkDir" type) dir)
|
||||
(state/pub-event! [:graph/dir-gone dir])
|
||||
|
||||
Reference in New Issue
Block a user