mirror of
https://github.com/org-roam/org-roam
synced 2025-08-03 12:27:23 -05:00
Compare commits
1 Commits
v2.3.1
...
migration/
Author | SHA1 | Date | |
---|---|---|---|
f5b8144c31 |
@ -78,23 +78,31 @@ To your init file.
|
|||||||
(when (yes-or-no-p "Org-roam will now convert all your notes from v1 to v2.
|
(when (yes-or-no-p "Org-roam will now convert all your notes from v1 to v2.
|
||||||
This will take a while. Are you sure you want to do this?")
|
This will take a while. Are you sure you want to do this?")
|
||||||
;; Back up notes
|
;; Back up notes
|
||||||
(let ((backup-dir (expand-file-name "org-roam.bak"
|
(let* ((parent-dir (f-parent org-roam-directory))
|
||||||
(file-name-directory (directory-file-name org-roam-directory)))))
|
(backup-dir (expand-file-name "org-roam.bak" parent-dir))
|
||||||
|
(debug-dir (expand-file-name "org-roam.debug" parent-dir)))
|
||||||
(message "Backing up files to %s" backup-dir)
|
(message "Backing up files to %s" backup-dir)
|
||||||
(copy-directory org-roam-directory backup-dir))
|
(copy-directory org-roam-directory backup-dir))
|
||||||
|
(condition-case err
|
||||||
|
(progn
|
||||||
|
;; Convert v1 to v2
|
||||||
|
(dolist (f (org-roam--list-all-files))
|
||||||
|
(org-roam-with-file f nil
|
||||||
|
(org-roam-migrate-v1-to-v2)))
|
||||||
|
;; Rebuild cache
|
||||||
|
(org-roam-db-sync 'force)
|
||||||
|
|
||||||
;; Convert v1 to v2
|
;;Replace all file links with ID links
|
||||||
(dolist (f (org-roam--list-all-files))
|
(dolist (f (org-roam--list-all-files))
|
||||||
(org-roam-with-file f nil
|
(org-roam-with-file f nil
|
||||||
(org-roam-migrate-v1-to-v2)))
|
(org-roam-migrate-replace-file-links-with-id)
|
||||||
;; Rebuild cache
|
(save-buffer))))
|
||||||
(org-roam-db-sync 'force)
|
(t
|
||||||
|
(rename-file org-roam-directory debug-dir)
|
||||||
;;Replace all file links with ID links
|
(rename-file backup-dir org-roam-directory)
|
||||||
(dolist (f (org-roam--list-all-files))
|
(lwarn 'org-roam :warning (format "The migration wizard failed with error:\n%s\n%s"
|
||||||
(org-roam-with-file f nil
|
(error-message-string err)
|
||||||
(org-roam-migrate-replace-file-links-with-id)
|
"Your files have been restored, consider filing an issue.\n"))))))
|
||||||
(save-buffer)))))
|
|
||||||
|
|
||||||
(defun org-roam-migrate-v1-to-v2 ()
|
(defun org-roam-migrate-v1-to-v2 ()
|
||||||
"Convert the current buffer to v2 format."
|
"Convert the current buffer to v2 format."
|
||||||
|
Reference in New Issue
Block a user