mirror of https://github.com/logseq/logseq
fix: empty path when importing roam's json
parent
eaeca30e58
commit
7238c4205a
|
@ -40,7 +40,8 @@
|
|||
files)
|
||||
files (remove nil? files)]
|
||||
(repo-handler/parse-files-and-load-to-db! repo files nil)
|
||||
(let [files (map (fn [{:file/keys [path content]}] [path content]) files)]
|
||||
(let [files (->> (map (fn [{:file/keys [path content]}] (when path [path content])) files)
|
||||
(remove nil?))]
|
||||
(file-handler/alter-files repo files {:add-history? false
|
||||
:update-db? false
|
||||
:update-status? false
|
||||
|
|
|
@ -249,27 +249,28 @@
|
|||
(defn alter-files-handler!
|
||||
[repo files {:keys [finish-handler chan]} file->content]
|
||||
(let [write-file-f (fn [[path content]]
|
||||
(let [original-content (get file->content path)]
|
||||
(-> (p/let [_ (or
|
||||
(util/electron?)
|
||||
(nfs/check-directory-permission! repo))]
|
||||
(debug/set-ack-step! path :write-file)
|
||||
(fs/write-file! repo (config/get-repo-dir repo) path content
|
||||
{:old-content original-content}))
|
||||
(p/catch (fn [error]
|
||||
(state/pub-event! [:notification/show
|
||||
{:content (str "Failed to save the file " path ". Error: "
|
||||
(str error))
|
||||
:status :error
|
||||
:clear? false}])
|
||||
(state/pub-event! [:instrument {:type :write-file/failed
|
||||
:payload {:path path
|
||||
:content-length (count content)
|
||||
:error-str (str error)
|
||||
:error error}}])
|
||||
(log/error :write-file/failed {:path path
|
||||
:content content
|
||||
:error error}))))))
|
||||
(when path
|
||||
(let [original-content (get file->content path)]
|
||||
(-> (p/let [_ (or
|
||||
(util/electron?)
|
||||
(nfs/check-directory-permission! repo))]
|
||||
(debug/set-ack-step! path :write-file)
|
||||
(fs/write-file! repo (config/get-repo-dir repo) path content
|
||||
{:old-content original-content}))
|
||||
(p/catch (fn [error]
|
||||
(state/pub-event! [:notification/show
|
||||
{:content (str "Failed to save the file " path ". Error: "
|
||||
(str error))
|
||||
:status :error
|
||||
:clear? false}])
|
||||
(state/pub-event! [:instrument {:type :write-file/failed
|
||||
:payload {:path path
|
||||
:content-length (count content)
|
||||
:error-str (str error)
|
||||
:error error}}])
|
||||
(log/error :write-file/failed {:path path
|
||||
:content content
|
||||
:error error})))))))
|
||||
finish-handler (fn []
|
||||
(when finish-handler
|
||||
(finish-handler))
|
||||
|
|
Loading…
Reference in New Issue