mirror of
https://github.com/logseq/logseq.git
synced 2026-05-29 15:09:41 +00:00
fix: handle wrong e2ee password on download
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
[frontend.handler.db-based.rtc-flows :as rtc-flows]
|
||||
[frontend.handler.db-based.sync :as rtc-handler]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.events.rtc-error :as rtc-error]
|
||||
[frontend.handler.export :as export]
|
||||
[frontend.handler.graph :as graph-handler]
|
||||
[frontend.handler.notification :as notification]
|
||||
@@ -57,13 +58,6 @@
|
||||
(defmulti handle first)
|
||||
|
||||
(defonce ^:private *search-index-build-timeout (atom nil))
|
||||
(def ^:private decrypt-aes-key-failed-notification
|
||||
"Failed to decrypt this graph.")
|
||||
|
||||
(defn- decrypt-aes-key-failed?
|
||||
[error]
|
||||
(string/includes? (or (ex-message error) (str error)) "decrypt-aes-key"))
|
||||
|
||||
(defn- <build-search-index!
|
||||
[repo]
|
||||
(-> (state/<invoke-db-worker :thread-api/search-build-blocks-indice-in-worker repo)
|
||||
@@ -389,8 +383,8 @@
|
||||
(println "RTC download graph failed, error:")
|
||||
(log/error :rtc-download-graph-failed e)
|
||||
(shui/popup-hide! :download-rtc-graph)
|
||||
(when (decrypt-aes-key-failed? e)
|
||||
(notification/show! decrypt-aes-key-failed-notification :error false))))))
|
||||
(when (rtc-error/download-decrypt-failed? e)
|
||||
(notification/show! (t :encryption/wrong-password) :error false))))))
|
||||
|
||||
;; db-worker -> UI
|
||||
(defmethod handle :db/sync-changes [[_ data]]
|
||||
|
||||
30
src/main/frontend/handler/events/rtc_error.cljs
Normal file
30
src/main/frontend/handler/events/rtc_error.cljs
Normal file
@@ -0,0 +1,30 @@
|
||||
(ns frontend.handler.events.rtc-error
|
||||
"RTC event error helpers."
|
||||
(:require [clojure.string :as string]))
|
||||
|
||||
(defn- throwable-message
|
||||
[error]
|
||||
(or (ex-message error)
|
||||
(when (instance? js/Error error)
|
||||
(.-message error))
|
||||
(some-> error str)))
|
||||
|
||||
(defn- error-texts
|
||||
[error]
|
||||
(when error
|
||||
(let [data (ex-data error)]
|
||||
(concat
|
||||
[(throwable-message error)
|
||||
(:error-message data)
|
||||
(:error-cause data)]
|
||||
(error-texts (:error data))
|
||||
(error-texts (ex-cause error))))))
|
||||
|
||||
(defn download-decrypt-failed?
|
||||
[error]
|
||||
(boolean
|
||||
(some (fn [text]
|
||||
(and (string? text)
|
||||
(or (string/includes? text "decrypt-aes-key")
|
||||
(string/includes? text "decrypt-private-key"))))
|
||||
(error-texts error))))
|
||||
Reference in New Issue
Block a user