From b8d8c99bd35222174c70dcfbf9a5ea05814f4141 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Tue, 26 Jul 2016 11:14:36 +0200 Subject: database: with-database: Keep the data. * src/cuirass/database.scm (with-database): Use 'db-open'. (db-open): Fallback to 'db-init' if DB do not exist. --- src/cuirass/database.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm index 09eeef4..5f616b5 100644 --- a/src/cuirass/database.scm +++ b/src/cuirass/database.scm @@ -97,7 +97,9 @@ database object." (define* (db-open #:optional (db (%package-database))) "Open database to store or read jobs and builds informations. Return a database object." - (sqlite-open db SQLITE_OPEN_READWRITE)) + (if (file-exists? db) + (sqlite-open db SQLITE_OPEN_READWRITE) + (db-init db))) (define (db-close db) "Close database object DB." @@ -167,7 +169,7 @@ INSERT INTO Evaluations (derivation, job_name, specification)\ (define-syntax-rule (with-database db body ...) "Run BODY with a connection to the database which is bound to DB in BODY." - (let ((db (db-init))) + (let ((db (db-open))) (dynamic-wind (const #t) (λ () body ...) -- cgit v1.2.3