aboutsummaryrefslogtreecommitdiff
path: root/nar-herder/database.scm
diff options
context:
space:
mode:
Diffstat (limited to 'nar-herder/database.scm')
-rw-r--r--nar-herder/database.scm53
1 files changed, 29 insertions, 24 deletions
diff --git a/nar-herder/database.scm b/nar-herder/database.scm
index 183966e..8ddfe6f 100644
--- a/nar-herder/database.scm
+++ b/nar-herder/database.scm
@@ -650,7 +650,10 @@ SELECT id FROM narinfos WHERE store_path = :store_path"
statement
#:store_path store-path)
- (let ((result (vector-ref (sqlite-step statement) 0)))
+ (let ((result
+ (and=> (sqlite-step statement)
+ (lambda (row)
+ (vector-ref row 0)))))
(sqlite-reset statement)
result)))
@@ -753,29 +756,31 @@ DELETE FROM narinfo_tags WHERE narinfo_id = :narinfo_id"
database
(lambda (db)
(let ((narinfo-id (store-path->narinfo-id db)))
- (if change-datetime
- (insert-change-with-datetime db store-path
- change-datetime)
- (insert-change db store-path))
-
- (remove-narinfo-files db narinfo-id)
- (remove-narinfo-references db narinfo-id)
- (remove-tags db narinfo-id)
-
- (for-each
- (lambda (cached-details)
- (database-remove-cached-narinfo-file
- database
- narinfo-id
- (symbol->string
- (assq-ref cached-details 'compression))))
- (database-select-cached-narinfo-files-by-narinfo-id
- database
- narinfo-id))
-
- (remove-narinfo-record db narinfo-id)
-
- #t))))
+ (if narinfo-id
+ (begin
+ (if change-datetime
+ (insert-change-with-datetime db store-path
+ change-datetime)
+ (insert-change db store-path))
+
+ (remove-narinfo-files db narinfo-id)
+ (remove-narinfo-references db narinfo-id)
+ (remove-tags db narinfo-id)
+
+ (for-each
+ (lambda (cached-details)
+ (database-remove-cached-narinfo-file
+ database
+ narinfo-id
+ (symbol->string
+ (assq-ref cached-details 'compression))))
+ (database-select-cached-narinfo-files-by-narinfo-id
+ database
+ narinfo-id))
+
+ (remove-narinfo-record db narinfo-id)
+ #t)
+ #f)))))
(define (database-select-narinfo-by-hash database hash)
(call-with-time-tracking