iens

Manager of links to read
git clone https://git.instinctive.eu/iens.git
Log | Files | Refs | README | LICENSE

commit 672070a3e0c0c6e166921b2f4183edd63e561727
parent aebfbf7544df46d50bb246c50aa74194dfe35876
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Sat, 27 Jul 2024 13:43:14 +0000

Tag lists are checked before partially acted on
Diffstat:
Msrc/iens.scm | 29++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/iens.scm b/src/iens.scm @@ -949,21 +949,28 @@ (print-tags* (car todo)) (loop (cdr todo)))))) + +(define (resolve-tag-id tag-name) + (let ((result (query fetch-value + (sql db "SELECT id from tag WHERE name=?;") + tag-name))) + (unless result + (write-line (conc "Unknown tag " tag-name))) + result)) + (define (exec-on-tags stmt mtime entry-id tag-list) (with-transaction db (lambda () (unless-protected entry-id - (let loop ((todo tag-list)) - (if (null? todo) - (exec (sql db "UPDATE entry SET mtime=? WHERE id=?;") - mtime entry-id) - (let ((tag-id (query fetch-value - (sql db "SELECT id FROM tag WHERE name=?;") - (car todo)))) - (if tag-id - (exec stmt entry-id tag-id) - (write-line (conc "Unknown tag " (car todo)))) - (loop (cdr todo)))))))) + (let ((tag-id-list (map resolve-tag-id tag-list))) + (when (every identity tag-id-list) + (let loop ((todo tag-id-list)) + (if (null? todo) + (exec (sql db "UPDATE entry SET mtime=? WHERE id=?;") + mtime entry-id) + (begin + (exec stmt entry-id (car todo)) + (loop (cdr todo)))))))))) (print-tags entry-id) (update-feed-cache mtime))