aboutsummaryrefslogtreecommitdiff
path: root/guix/scripts/locate.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/scripts/locate.scm')
-rw-r--r--guix/scripts/locate.scm26
1 files changed, 18 insertions, 8 deletions
diff --git a/guix/scripts/locate.scm b/guix/scripts/locate.scm
index ae64f46896..963ff2bf57 100644
--- a/guix/scripts/locate.scm
+++ b/guix/scripts/locate.scm
@@ -114,14 +114,24 @@ alter table Packages
add column output text;
")))
+;; XXX: missing in guile-sqlite3@0.1.3
+(define SQLITE_BUSY 5)
+
(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 who code errmsg)
+ (if (= code SQLITE_BUSY)
+ (leave (G_ "~a: database is locked by another process~%")
+ file)
+ (throw key who code errmsg)))))
(define (ensure-latest-database-schema db)
"Ensure DB follows the latest known version of the schema."
@@ -657,7 +667,7 @@ Locate FILE and return the list of packages that contain it.\n"))
files)))
(()
(if (null? files)
- (unless update?
+ (unless (or update? (assoc-ref opts 'clear?))
(leave (G_ "no files to search for~%")))
(leave (N_ "file~{ '~a'~} not found in database '~a'~%"
"files~{ '~a'~} not found in database '~a'~%"