Skip to content
Snippets Groups Projects
Unverified Commit b8d8c99b authored by Mathieu Lirzin's avatar Mathieu Lirzin
Browse files

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.
parent f40ac8a5
No related branches found
No related tags found
No related merge requests found
......@@ -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 ...)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment