mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix): fix link expansion on URL links (#1103)
Attempting to perform link expansion on URL links caused extreme slowdowns in Windows environment. Ref #1038 #1067. Co-authored-by: Noboru Ota <me@nobiot.com>
This commit is contained in:
@ -25,6 +25,7 @@ In this release we support fuzzy links of the form `[[Title]]`, `[[*Headline]]`
|
|||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
- [#1057](https://github.com/org-roam/org-roam/pull/1057) Improve performance of database builds by preventing generation of LaTeX and image previews.
|
- [#1057](https://github.com/org-roam/org-roam/pull/1057) Improve performance of database builds by preventing generation of LaTeX and image previews.
|
||||||
|
- [#1103](https://github.com/org-roam/org-roam/pull/1103) Fix long build-times for Windows on files with URL links
|
||||||
|
|
||||||
## 1.2.1 (27-07-2020)
|
## 1.2.1 (27-07-2020)
|
||||||
|
|
||||||
|
21
org-roam.el
21
org-roam.el
@ -335,6 +335,12 @@ function are expected to catch the error."
|
|||||||
(t
|
(t
|
||||||
(signal 'wrong-type-argument `((stringp numberp symbolp) ,item))))) items))))
|
(signal 'wrong-type-argument `((stringp numberp symbolp) ,item))))) items))))
|
||||||
|
|
||||||
|
(defun org-roam--url-p (path)
|
||||||
|
"Check if PATH is a URL.
|
||||||
|
Assume the protocol is not present in PATH; e.g. URL `https://google.com' is
|
||||||
|
passed as `//google.com'."
|
||||||
|
(string-prefix-p "//" path))
|
||||||
|
|
||||||
;;;; File functions and predicates
|
;;;; File functions and predicates
|
||||||
(defun org-roam--file-name-extension (filename)
|
(defun org-roam--file-name-extension (filename)
|
||||||
"Return file name extension for FILENAME.
|
"Return file name extension for FILENAME.
|
||||||
@ -525,21 +531,19 @@ The search terminates when the first property is encountered."
|
|||||||
"Crawl CONTENT for relative links and expand them.
|
"Crawl CONTENT for relative links and expand them.
|
||||||
PATH should be the root from which to compute the relativity."
|
PATH should be the root from which to compute the relativity."
|
||||||
(let ((dir (file-name-directory path))
|
(let ((dir (file-name-directory path))
|
||||||
link link-type)
|
link)
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert content)
|
(insert content)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
;; Loop over links
|
;; Loop over links
|
||||||
(while (re-search-forward org-roam--org-link-bracket-typed-re (point-max) t)
|
(while (re-search-forward org-roam--org-link-bracket-typed-re (point-max) t)
|
||||||
|
(setq link (match-string 2))
|
||||||
|
(when (f-relative-p link)
|
||||||
|
(save-excursion
|
||||||
(goto-char (match-beginning 2))
|
(goto-char (match-beginning 2))
|
||||||
(setq link-type (match-string 1)
|
|
||||||
link (match-string 2))
|
|
||||||
;; Delete relative link
|
|
||||||
(when (and (member link-type '("file")) ; TODO: Fix this
|
|
||||||
(f-relative-p link))
|
|
||||||
(delete-region (match-beginning 2)
|
(delete-region (match-beginning 2)
|
||||||
(match-end 2))
|
(match-end 2))
|
||||||
(insert (expand-file-name link dir))))
|
(insert (expand-file-name link dir)))))
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
|
|
||||||
(defun org-roam--get-outline-path ()
|
(defun org-roam--get-outline-path ()
|
||||||
@ -623,7 +627,8 @@ it as FILE-PATH."
|
|||||||
(setq type "cite")
|
(setq type "cite")
|
||||||
(org-ref-split-and-strip-string path))
|
(org-ref-split-and-strip-string path))
|
||||||
("fuzzy" (list path))
|
("fuzzy" (list path))
|
||||||
(_ (if (file-remote-p path)
|
(_ (if (or (file-remote-p path)
|
||||||
|
(org-roam--url-p path))
|
||||||
(list path)
|
(list path)
|
||||||
(let ((file-maybe (file-truename
|
(let ((file-maybe (file-truename
|
||||||
(expand-file-name path (file-name-directory file-path)))))
|
(expand-file-name path (file-name-directory file-path)))))
|
||||||
|
Reference in New Issue
Block a user