Subject: [PATCH] add guix locate database is locked error message(resent)
From: Maciej Kalandyk <[email-masked]>
To: [email-masked]
Cc: Maciej Kalandyk <[email-masked]>
Date: Sat, 18 Nov 2023 01:30:39 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Change-Id: Iebe76c75d45e70317bd18d2c176dcdeaf9d6964c
Signed-off-by: Maciej Kalandyk <[email-masked]>
---
 guix/scripts/locate.scm | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/guix/scripts/locate.scm b/guix/scripts/locate.scm
index ae64f46896..c24e969be7 100644
--- a/guix/scripts/locate.scm
+++ b/guix/scripts/locate.scm
@@ -115,13 +115,21 @@ (define schema-to-migrate '((1 . "
 ")))
 
 (define (call-with-database file proc)
-  (let ((db (sqlite-open file)))
-    (dynamic-wind
-      (lambda () #t)
-      (lambda ()
-        (ensure-latest-database-schema db)
-        (proc db))
-      (lambda () (sqlite-close db)))))
+  (catch 'sqlite-error
+    (lambda ()
+      (let ((db (sqlite-open file)))
+        (dynamic-wind
+          (lambda () #t)
+          (lambda ()
+            (ensure-latest-database-schema db)
+            (proc db))
+          (lambda () (sqlite-close db)))))
+    (lambda (key . args)
+      (match args
+        [(_ 5 _)
+         (leave (G_ "database ~a is locked by another process~%")
+                file)]
+        [_ (apply throw (cons key args))]))))
 
 (define (ensure-latest-database-schema db)
   "Ensure DB follows the latest known version of the schema."

base-commit: a0d337e79c87d7c38c79d0291974f490cb137a52
-- 
2.41.0