mirror of https://github.com/logseq/logseq
parent
43d31d5d4d
commit
a7c7fa51cd
|
@ -181,7 +181,10 @@
|
||||||
;; :local-last-modified-at local-last-modified-at
|
;; :local-last-modified-at local-last-modified-at
|
||||||
;; :not-changed? not-changed?
|
;; :not-changed? not-changed?
|
||||||
;; :new-created? new-created?
|
;; :new-created? new-created?
|
||||||
;; :pending-writes pending-writes})
|
;; :pending-writes pending-writes
|
||||||
|
;; :local-content local-content
|
||||||
|
;; :old-content old-content
|
||||||
|
;; :new? new?})
|
||||||
(if (and local-content old-content new?
|
(if (and local-content old-content new?
|
||||||
(or
|
(or
|
||||||
(> pending-writes 0)
|
(> pending-writes 0)
|
||||||
|
@ -234,10 +237,15 @@
|
||||||
;; delete old file
|
;; delete old file
|
||||||
(p/let [[dir basename] (util/get-dir-and-basename old-path)
|
(p/let [[dir basename] (util/get-dir-and-basename old-path)
|
||||||
[_ new-basename] (util/get-dir-and-basename new-path)
|
[_ new-basename] (util/get-dir-and-basename new-path)
|
||||||
|
parts (->> (string/split new-path "/")
|
||||||
|
(remove string/blank?))
|
||||||
|
dir (str "/" (first parts))
|
||||||
|
new-path (->> (rest parts)
|
||||||
|
(string/join "/"))
|
||||||
handle (idb/get-item (str "handle" old-path))
|
handle (idb/get-item (str "handle" old-path))
|
||||||
file (.getFile handle)
|
file (.getFile handle)
|
||||||
content (.text file)
|
content (.text file)
|
||||||
_ (write-file repo dir new-basename content)]
|
_ (write-file repo dir new-path content)]
|
||||||
(unlink old-path nil))
|
(unlink old-path nil))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
|
|
|
@ -294,23 +294,23 @@
|
||||||
(let [repo (state/get-current-repo)
|
(let [repo (state/get-current-repo)
|
||||||
old-path (:file/path file)
|
old-path (:file/path file)
|
||||||
new-path (compute-new-file-path old-path new-name)]
|
new-path (compute-new-file-path old-path new-name)]
|
||||||
|
;; update db
|
||||||
|
(db/transact! repo [{:db/id (:db/id file)
|
||||||
|
:file/path new-path}])
|
||||||
|
|
||||||
|
;; update files db
|
||||||
|
(let [conn (db/get-files-conn repo)]
|
||||||
|
(when-let [file (d/entity (d/db conn) [:file/path old-path])]
|
||||||
|
(d/transact! conn [{:db/id (:db/id file)
|
||||||
|
:file/path new-path}])))
|
||||||
(->
|
(->
|
||||||
(p/let [_ (fs/rename repo
|
(p/let [_ (fs/rename repo
|
||||||
(str (util/get-repo-dir repo) "/" old-path)
|
(str (util/get-repo-dir repo) "/" old-path)
|
||||||
(str (util/get-repo-dir repo) "/" new-path))]
|
(str (util/get-repo-dir repo) "/" new-path))
|
||||||
;; update db
|
_ (when-not (config/local-db? repo)
|
||||||
(db/transact! repo [{:db/id (:db/id file)
|
(git/rename repo old-path new-path))]
|
||||||
:file/path new-path}])
|
(common-handler/check-changed-files-status)
|
||||||
|
(ok-handler))
|
||||||
;; update files db
|
|
||||||
(let [conn (db/get-files-conn repo)]
|
|
||||||
(when-let [file (d/entity (d/db conn) [:file/path old-path])]
|
|
||||||
(d/transact! conn [{:db/id (:db/id file)
|
|
||||||
:file/path new-path}])))
|
|
||||||
|
|
||||||
(p/let [_ (git/rename repo old-path new-path)]
|
|
||||||
(common-handler/check-changed-files-status)
|
|
||||||
(ok-handler)))
|
|
||||||
(p/catch (fn [error]
|
(p/catch (fn [error]
|
||||||
(println "file rename failed: " error))))))
|
(println "file rename failed: " error))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue