lisp/ox-publish.el: Use publish time in publish cache

* lisp/ox-publish.el (org-publish-update-timestamp): Store current
time in publish cache, instead of modification time of source file.
(org-publish-cache-file-needs-publishing): Return t, if source or an
included file was modified more recently.

Previously, a source file including a newer file was published again
and again.  Now, publishing only happens if either source or an
included file changed since the last publishing.
This commit is contained in:
Jens Lechtenbörger 2024-08-12 09:40:13 +02:00 committed by Ihor Radchenko
parent 50be048ad0
commit 38d1bc67b2
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 6 additions and 5 deletions

View File

@ -389,7 +389,7 @@ still decide about that independently."
"Update publishing timestamp for file FILENAME.
If there is no timestamp, create one."
(let ((key (org-publish-timestamp-filename filename pub-dir pub-func))
(stamp (org-publish-cache-mtime-of-src filename)))
(stamp (current-time)))
(org-publish-cache-set key stamp)))
(defun org-publish-remove-all-timestamps ()
@ -1286,9 +1286,10 @@ If FREE-CACHE, empty the cache."
(defun org-publish-cache-file-needs-publishing
(filename &optional pub-dir pub-func _base-dir)
"Check the timestamp of the last publishing of FILENAME.
Return non-nil if the file needs publishing. Also check if
any included files have been more recently published, so that
the file including them will be republished as well."
Return non-nil if the file needs publishing. This is the case
if either FILENAME does not occur in the publication cache or
if FILENAME, or any file included by it, was modified after the
most recent publication."
(unless org-publish-cache
(error
"`org-publish-cache-file-needs-publishing' called, but no cache present"))
@ -1322,7 +1323,7 @@ the file including them will be republished as well."
(or (null pstamp)
(let ((mtime (org-publish-cache-mtime-of-src filename)))
(or (time-less-p pstamp mtime)
(cl-some (lambda (ct) (time-less-p mtime ct))
(cl-some (lambda (ct) (time-less-p pstamp ct))
included-files-mtime))))))
(defun org-publish-cache-set-file-property