org-babel-jupyter-cleanup-file-links: Handle links with no directory

This commit is contained in:
Nathaniel Nicandro 2019-01-26 16:15:21 -06:00
parent ee62fafdf6
commit ee1078d0c7
No known key found for this signature in database
GPG key ID: C34814B309DD06B8

View file

@ -223,10 +223,13 @@ Do this only if the file exists in
;; This assumes that `jupyter-org-client' only emits bracketed links as
;; images
(while (re-search-forward link-re bound t)
(let* ((link-path (org-element-property :path (org-element-context)))
(link-dir (expand-file-name (file-name-directory link-path)))
(resource-dir
(expand-file-name org-babel-jupyter-resource-directory)))
(when-let* ((link-path
(org-element-property :path (org-element-context)))
(link-dir
(when (file-name-directory link-path)
(expand-file-name (file-name-directory link-path))))
(resource-dir
(expand-file-name org-babel-jupyter-resource-directory)))
(when (and (equal link-dir resource-dir)
(file-exists-p link-path))
(delete-file link-path))))))))