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:
Tienson Qin
2022-11-04 22:28:23 +08:00
parent daa2590cc9
commit 2dfac3d774
18 changed files with 61 additions and 417 deletions

View File

@@ -14,7 +14,6 @@
[promesa.core :as p]
[frontend.db :as db]
[clojure.string :as string]
[frontend.encrypt :as encrypt]
[frontend.state :as state]))
(defonce nfs-record (nfs/->Nfs))
@@ -77,29 +76,27 @@
[repo dir path content opts]
(when content
(let [fs-record (get-fs dir)]
(p/let [md-or-org? (contains? #{"md" "markdown" "org"} (util/get-file-ext path))
content (if-not md-or-org? content (encrypt/encrypt content))]
(->
(p/let [opts (assoc opts
:error-handler
(fn [error]
(state/pub-event! [:instrument {:type :write-file/failed
:payload {:fs (type fs-record)
:user-agent (when js/navigator js/navigator.userAgent)
:path path
:content-length (count content)
:error-str (str error)
:error error}}])))
_ (protocol/write-file! (get-fs dir) repo dir path content opts)]
(when (= bfs-record fs-record)
(db/set-file-last-modified-at! repo (config/get-file-path repo path) (js/Date.))))
(p/catch (fn [error]
(log/error :file/write-failed {:dir dir
:path path
:error error})
;; Disable this temporarily
;; (js/alert "Current file can't be saved! Please copy its content to your local file system and click the refresh button.")
)))))))
(->
(p/let [opts (assoc opts
:error-handler
(fn [error]
(state/pub-event! [:instrument {:type :write-file/failed
:payload {:fs (type fs-record)
:user-agent (when js/navigator js/navigator.userAgent)
:path path
:content-length (count content)
:error-str (str error)
:error error}}])))
_ (protocol/write-file! (get-fs dir) repo dir path content opts)]
(when (= bfs-record fs-record)
(db/set-file-last-modified-at! repo (config/get-file-path repo path) (js/Date.))))
(p/catch (fn [error]
(log/error :file/write-failed {:dir dir
:path path
:error error})
;; Disable this temporarily
;; (js/alert "Current file can't be saved! Please copy its content to your local file system and click the refresh button.")
))))))
(defn read-file
([dir path]