diff options
author | Mathieu Lirzin <mthl@gnu.org> | 2016-07-26 11:14:36 +0200 |
---|---|---|
committer | Mathieu Lirzin <mthl@gnu.org> | 2016-07-26 11:40:51 +0200 |
commit | b8d8c99bd35222174c70dcfbf9a5ea05814f4141 (patch) | |
tree | 8930a544f936a1cb77b8323d4cfb383e660f9f88 | |
parent | f40ac8a535f0084348f6aa17b52f75826f606da2 (diff) | |
download | cuirass-b8d8c99bd35222174c70dcfbf9a5ea05814f4141.tar cuirass-b8d8c99bd35222174c70dcfbf9a5ea05814f4141.tar.gz |
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.
-rw-r--r-- | src/cuirass/database.scm | 6 |
1 files 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 ...) |