diff options
Diffstat (limited to 'nar-herder')
-rw-r--r-- | nar-herder/database.scm | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/nar-herder/database.scm b/nar-herder/database.scm index 8ddfe6f..e5e4905 100644 --- a/nar-herder/database.scm +++ b/nar-herder/database.scm @@ -28,6 +28,7 @@ #:use-module (sqlite3) #:use-module (fibers) #:use-module (prometheus) + #:use-module (guix store) #:use-module (guix narinfo) #:use-module (guix derivations) #:use-module (nar-herder utils) @@ -638,26 +639,6 @@ INSERT INTO narinfo_tags (narinfo_id, tag_id) VALUES (:narinfo_id, :tag_id)" (define* (database-remove-narinfo database store-path #:key change-datetime) - (define (store-path->narinfo-id db) - (let ((statement - (sqlite-prepare - db - " -SELECT id FROM narinfos WHERE store_path = :store_path" - #:cache? #t))) - - (sqlite-bind-arguments - statement - #:store_path store-path) - - (let ((result - (and=> (sqlite-step statement) - (lambda (row) - (vector-ref row 0))))) - (sqlite-reset statement) - - result))) - (define (remove-narinfo-record db id) (let ((statement (sqlite-prepare @@ -755,9 +736,13 @@ DELETE FROM narinfo_tags WHERE narinfo_id = :narinfo_id" (database-call-with-transaction database (lambda (db) - (let ((narinfo-id (store-path->narinfo-id db))) - (if narinfo-id - (begin + (let ((narinfo-details + (database-select-narinfo-by-hash + database + (store-path-hash-part store-path)))) + (if narinfo-details + (let ((narinfo-id (assq-ref narinfo-details + 'id))) (if change-datetime (insert-change-with-datetime db store-path change-datetime) |