diff options
author | Arun Isaac | 2022-07-04 23:59:29 +0530 |
---|---|---|
committer | Arun Isaac | 2022-07-05 00:06:09 +0530 |
commit | ec434ea0710e9ece9f5239c7fe2b1f965a53bea1 (patch) | |
tree | 3336fc68e91724ddf7cc8cf91474d02212c5e59f /bin | |
parent | c29b254f7cec9940e2a9e5fd33ff3687f6986508 (diff) | |
download | tissue-ec434ea0710e9ece9f5239c7fe2b1f965a53bea1.tar.gz tissue-ec434ea0710e9ece9f5239c7fe2b1f965a53bea1.tar.lz tissue-ec434ea0710e9ece9f5239c7fe2b1f965a53bea1.zip |
bin: Move stale index checks to main function.
We want `tissue pull' to unconditionally rebuild the index. Hence, we
move stale index checks out of the index function.
* bin/tissue (index): Do not check if index is stale. Always rebuild
index.
(main): Call the index function only when index is stale.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/tissue | 55 |
1 files changed, 28 insertions, 27 deletions
@@ -298,32 +298,27 @@ To get usage information for one of these sub-commands, run (command-line-program))) (define (index db-path) - "Index current repository into xapian database at DB-PATH. If DB-PATH -already exists and is up to date, do nothing." - (let ((current-head - (oid->string (reference-name->oid (current-git-repository) "HEAD")))) - (unless (and (file-exists? db-path) - (string=? (call-with-database db-path - (cut Database-get-metadata <> "commit")) - current-head)) - (guard (c (else (delete-file-recursively db-path) - (format (current-error-port) - "Building xapian index failed.~%") - (raise c))) - (delete-file-recursively db-path) - (call-with-writable-database db-path - (lambda (db) - (for-each (lambda (indexed-document) - (let* ((document (slot-set ((indexed-document-reader indexed-document)) - 'web-uri - (indexed-document-web-uri indexed-document))) - (term-generator (document-term-generator document))) - (index-text! term-generator (document-type document) #:prefix "XT") - (replace-document! db - (document-id-term document) - (TermGenerator-get-document term-generator)))) - (tissue-configuration-indexed-documents (load-config))) - (WritableDatabase-set-metadata db "commit" current-head))))))) + "Index current repository into xapian database at DB-PATH." + (guard (c (else (delete-file-recursively db-path) + (format (current-error-port) + "Building xapian index failed.~%") + (raise c))) + (delete-file-recursively db-path) + (call-with-writable-database db-path + (lambda (db) + (for-each (lambda (indexed-document) + (let* ((document (slot-set ((indexed-document-reader indexed-document)) + 'web-uri + (indexed-document-web-uri indexed-document))) + (term-generator (document-term-generator document))) + (index-text! term-generator (document-type document) #:prefix "XT") + (replace-document! db + (document-id-term document) + (TermGenerator-get-document term-generator)))) + (tissue-configuration-indexed-documents (load-config))) + (WritableDatabase-set-metadata + db "commit" (oid->string (reference-name->oid + (current-git-repository) "HEAD"))))))) (define (pull state-directory hostname upstream-repository) "Pull latest from UPSTREAM-REPOSITORY into STATE-DIRECTORY for @@ -466,7 +461,13 @@ Pull latest from upstream repositories. (unless (file-exists? %state-directory) (mkdir %state-directory)) ;; Ensure index exists, rebuilding it if it is stale. - (index %xapian-index) + (let ((current-head + (oid->string (reference-name->oid (current-git-repository) "HEAD")))) + (unless (and (file-exists? db-path) + (string=? (call-with-database db-path + (cut Database-get-metadata <> "commit")) + current-head)) + (index %xapian-index))) ;; Handle sub-command. (apply (match command ("search" tissue-search) |