diff --git a/linkwave.scm b/linkwave.scm index f36c5e2..235615b 100644 --- a/linkwave.scm +++ b/linkwave.scm @@ -26,7 +26,13 @@ (set! tag-id (last-insert-rowid db))) (execute db "INSERT INTO bookmark_tag VALUES (?, ?)" bookmark-id tag-id))) - tags))) + tags)) + #t) + +(define (url-string? str) + (and (> (string-length str) 7) + (or (string= (substring str 0 7) "http://") + (string= (substring str 0 8) "https://")))) (define db (open-database (data-file "linkwave.db"))) @@ -34,8 +40,9 @@ (if (null? cla) (for-each-row print-row db "select * from bookmark") (cond - ((and (>= (string-length (car cla)) 7) (string= (substring (car cla) 0 7) "http://")) - (add-bookmark (car cla) (cadr cla) (caddr cla) (cdddr cla))) + ((url-string? (car cla)) + (with-transaction + db (lambda () (add-bookmark (car cla) (cadr cla) (caddr cla) (cdddr cla))))) (else (format #t "Unrecognized option: ~a~%" (car cla))))))