(fix): index file: prevent malformed absolute path (#1346)

When `org-roam-directory` doesn't end with trailing slash and
`org-roam-index-file` contains relative filename, absolute path
to org-roam index file returned by `org-roam--get-index-path` is
malformed and invalid.

Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
This commit is contained in:
Alois Janíček
2020-12-16 13:31:32 +01:00
committed by GitHub
parent 9c23218553
commit 57cfb3dbb7
2 changed files with 9 additions and 11 deletions

View File

@ -11,6 +11,7 @@
- [#1308](https://github.com/org-roam/org-roam/pull/1308) fixed file renames corrupting database - [#1308](https://github.com/org-roam/org-roam/pull/1308) fixed file renames corrupting database
- [#1325](https://github.com/org-roam/org-roam/pull/1325) make titles and tags extracted unique per note - [#1325](https://github.com/org-roam/org-roam/pull/1325) make titles and tags extracted unique per note
- [#1327](https://github.com/org-roam/org-roam/pull/1327) preserve existing link description during automatic replacement - [#1327](https://github.com/org-roam/org-roam/pull/1327) preserve existing link description during automatic replacement
- [#1346](https://github.com/org-roam/org-roam/pull/1346) prevent malformed path to `org-roam-index-file`
## 1.2.3 (13-11-2020) ## 1.2.3 (13-11-2020)

View File

@ -868,17 +868,14 @@ plist containing the path and title for the file."
The path to the index can be defined in `org-roam-index-file'. The path to the index can be defined in `org-roam-index-file'.
Otherwise, it is assumed to be a note in `org-roam-directory' Otherwise, it is assumed to be a note in `org-roam-directory'
whose title is 'Index'." whose title is 'Index'."
(let* ((index org-roam-index-file) (let ((path (pcase org-roam-index-file
(path (pcase index ((pred functionp) (funcall org-roam-index-file))
((pred functionp) (funcall index)) ((pred stringp) org-roam-index-file)
((pred stringp) index) ('nil (user-error "You need to set `org-roam-index-file' before you can jump to it"))
('nil (user-error "You need to set `org-roam-index-file' before you can jump to it")) (wrong-type (signal 'wrong-type-argument
(wrong-type (signal 'wrong-type-argument `((functionp stringp)
`((functionp stringp) ,wrong-type))))))
,wrong-type)))))) (expand-file-name path org-roam-directory)))
(if (f-relative-p index)
(concat (expand-file-name org-roam-directory) path)
index)))
;;;; dealing with file-wide properties ;;;; dealing with file-wide properties
(defun org-roam--set-global-prop (name value) (defun org-roam--set-global-prop (name value)