mirror of https://github.com/logseq/logseq
parent
43d31d5d4d
commit
a7c7fa51cd
|
@ -181,7 +181,10 @@
|
|||
;; :local-last-modified-at local-last-modified-at
|
||||
;; :not-changed? not-changed?
|
||||
;; :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?
|
||||
(or
|
||||
(> pending-writes 0)
|
||||
|
@ -234,10 +237,15 @@
|
|||
;; delete old file
|
||||
(p/let [[dir basename] (util/get-dir-and-basename old-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))
|
||||
file (.getFile handle)
|
||||
content (.text file)
|
||||
_ (write-file repo dir new-basename content)]
|
||||
_ (write-file repo dir new-path content)]
|
||||
(unlink old-path nil))
|
||||
|
||||
:else
|
||||
|
|
|
@ -294,23 +294,23 @@
|
|||
(let [repo (state/get-current-repo)
|
||||
old-path (:file/path file)
|
||||
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
|
||||
(str (util/get-repo-dir repo) "/" old-path)
|
||||
(str (util/get-repo-dir repo) "/" new-path))]
|
||||
;; 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 [_ (git/rename repo old-path new-path)]
|
||||
(common-handler/check-changed-files-status)
|
||||
(ok-handler)))
|
||||
(str (util/get-repo-dir repo) "/" new-path))
|
||||
_ (when-not (config/local-db? repo)
|
||||
(git/rename repo old-path new-path))]
|
||||
(common-handler/check-changed-files-status)
|
||||
(ok-handler))
|
||||
(p/catch (fn [error]
|
||||
(println "file rename failed: " error))))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue