From 87024bdf7199869120788522cea08fa77635afcf Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 4 Jan 2022 02:58:28 -0500 Subject: [PATCH] Copy the ltximg dir to static only if the source dir has changed That would happen when a file is added/removed in the source ltximg dir --- ox-hugo.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ox-hugo.el b/ox-hugo.el index 813810a4..a3620cd1 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -2089,8 +2089,8 @@ and rewrite link paths to make blogging more seamless." (when (and (stringp raw-path) link-is-url) - (setq raw-path (org-blackfriday--url-sanitize-maybe info - (url-encode-url raw-path)))) + (setq raw-path (org-blackfriday--url-sanitize-maybe + info (url-encode-url raw-path)))) ;; (message "[ox-hugo-link DBG] link: %S" link) ;; (message "[ox-hugo-link DBG] link path: %s" (org-element-property :path link)) ;; (message "[ox-hugo-link DBG] link filename: %s" (expand-file-name (plist-get (car (cdr link)) :path))) @@ -2462,10 +2462,12 @@ INFO is a plist used as a communication channel." (expand-file-name org-blackfriday--ltximg-directory (expand-file-name "static" hugo-base-dir)))))) - (copy-directory org-preview-latex-image-directory static-ltximg-dir - nil :parents :copy-contents) - (message "[ox-hugo] Copied contents of %S into %S" - org-preview-latex-image-directory static-ltximg-dir)))) + (when (file-newer-than-file-p + org-preview-latex-image-directory static-ltximg-dir) + (copy-directory org-preview-latex-image-directory static-ltximg-dir + nil :parents :copy-contents) + (message "[ox-hugo] Copied contents of %S into %S" + org-preview-latex-image-directory static-ltximg-dir))))) (defun org-hugo--attachment-rewrite-maybe (path info) "Copy local images and pdfs to the static/bundle directory if needed.