mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: readdir
also, fix warnings on persist var
This commit is contained in:
@@ -38,12 +38,14 @@
|
||||
(defn read-graphs-txid-info
|
||||
[root]
|
||||
(when (string? root)
|
||||
(-> (p/let [txid-str (fs/read-file root "logseq/graphs-txid.edn")
|
||||
txid-meta (and txid-str (reader/read-string txid-str))]
|
||||
txid-meta)
|
||||
(p/catch
|
||||
(fn [^js e]
|
||||
(js/console.error "[fs read txid data error]" e))))))
|
||||
(p/let [exists? (fs/file-exists? root "logseq/graphs-txid.edn")]
|
||||
(when exists?
|
||||
(-> (p/let [txid-str (fs/read-file root "logseq/graphs-txid.edn")
|
||||
txid-meta (and txid-str (reader/read-string txid-str))]
|
||||
txid-meta)
|
||||
(p/catch
|
||||
(fn [^js e]
|
||||
(js/console.error "[fs read txid data error]" e))))))))
|
||||
|
||||
(defn inflate-graphs-info
|
||||
[graphs]
|
||||
|
||||
@@ -32,24 +32,26 @@
|
||||
(let [repo (state/get-current-repo)
|
||||
dir (config/get-repo-dir repo)
|
||||
path (load-path location)]
|
||||
(-> (p/chain (fs/stat dir path)
|
||||
(fn [stat]
|
||||
(when stat
|
||||
(fs/read-file dir path)))
|
||||
(fn [content]
|
||||
(when (not-empty content)
|
||||
(try (cljs.reader/read-string content)
|
||||
(catch js/Error e
|
||||
(println (util/format "read persist-var failed: %s" (load-path location)))
|
||||
(js/console.dir e)))))
|
||||
(fn [value]
|
||||
(when (some? value)
|
||||
(swap! *value (fn [o]
|
||||
(-> o
|
||||
(assoc-in [repo :loaded?] true)
|
||||
(assoc-in [repo :value] value)))))))
|
||||
(p/catch (fn [e]
|
||||
(println (util/format "load persist-var failed: %s: %s" (load-path location) e))))))))
|
||||
(p/let [file-exists? (fs/file-exists? dir path)]
|
||||
(when file-exists?
|
||||
(-> (p/chain (fs/stat dir path)
|
||||
(fn [stat]
|
||||
(when stat
|
||||
(fs/read-file dir path)))
|
||||
(fn [content]
|
||||
(when (not-empty content)
|
||||
(try (cljs.reader/read-string content)
|
||||
(catch js/Error e
|
||||
(println (util/format "read persist-var failed: %s" (load-path location)))
|
||||
(js/console.dir e)))))
|
||||
(fn [value]
|
||||
(when (some? value)
|
||||
(swap! *value (fn [o]
|
||||
(-> o
|
||||
(assoc-in [repo :loaded?] true)
|
||||
(assoc-in [repo :value] value)))))))
|
||||
(p/catch (fn [e]
|
||||
(println (util/format "load persist-var failed: %s: %s" (load-path location) e))))))))))
|
||||
(-loaded? [_]
|
||||
(get-in @*value [(state/get-current-repo) :loaded?]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user