org-persist: Do not re-download url files on write

* lisp/org-persist.el (org-persist-write:url): Since the url write
function is called as part of `org-persist-write-all', it is worth
adding a check to avoid re-downloading the file if a file already exists
in the expected location.
This commit is contained in:
TEC 2022-12-11 01:41:39 +08:00
parent 534633d508
commit 1a9d0850b6
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 7 additions and 6 deletions

View File

@ -664,12 +664,13 @@ COLLECTION is the plist holding data collection."
(file-copy (org-file-name-concat
org-persist-directory
(format "%s-%s.%s" persist-file (md5 path) ext))))
(unless (file-exists-p (file-name-directory file-copy))
(make-directory (file-name-directory file-copy) t))
(if (org--should-fetch-remote-resource-p path)
(url-copy-file path file-copy 'overwrite)
(error "The remote resource %S is considered unsafe, and will not be downloaded."
path))
(unless (file-exists-p file-copy)
(unless (file-exists-p (file-name-directory file-copy))
(make-directory (file-name-directory file-copy) t))
(if (org--should-fetch-remote-resource-p path)
(url-copy-file path file-copy 'overwrite)
(error "The remote resource %S is considered unsafe, and will not be downloaded."
path)))
(format "%s-%s.%s" persist-file (md5 path) ext)))))
(defun org-persist-write:index (container _)