From 02c19cf48d9ddc36286a7b7527795f46ca647c11 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 4 Jul 2022 00:29:46 +0530 Subject: bin: Generalize delete-xapian-index to delete-directory. * bin/tissue (delete-xapian-index): Generalize to delete-directory. (main): Use delete-directory instead of delete-xapian-index. --- bin/tissue | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/tissue b/bin/tissue index 7e0f7f4..bcc85f9 100755 --- a/bin/tissue +++ b/bin/tissue @@ -295,15 +295,14 @@ To get usage information for one of these sub-commands, run (command-line-program) (command-line-program))) -(define (delete-xapian-index) - "Delete xapian index if it exists. Current directory must be at the -top-level of the git repository." - (when (file-exists? %xapian-index) +(define (delete-directory directory) + "Delete DIRECTORY, and the contained files, it if it exists." + (when (file-exists? directory) (for-each (lambda (file) - (delete-file (string-append %xapian-index "/" file))) - (scandir %xapian-index + (delete-file (string-append directory "/" file))) + (scandir directory (negate (cut member <> (list "." ".."))))) - (rmdir %xapian-index))) + (rmdir directory))) (define main (match-lambda* @@ -327,11 +326,11 @@ top-level of the git repository." (string=? (call-with-database %xapian-index (cut Database-get-metadata <> "commit")) current-head)) - (guard (c (else (delete-xapian-index) + (guard (c (else (delete-directory %xapian-index) (display "Building xapian index failed." (current-error-port)) (raise c))) - (delete-xapian-index) + (delete-directory %xapian-index) (call-with-writable-database %xapian-index (lambda (db) (for-each (lambda (indexed-document) -- cgit v1.2.3