aboutsummaryrefslogtreecommitdiff
path: root/nar-herder/database.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-02-06 15:58:09 +0100
committerChristopher Baines <mail@cbaines.net>2023-02-06 15:58:09 +0100
commitd3d9a365fc9aa09c3d6e4d5b80126976d4b39961 (patch)
tree2134e25d1eb32580ab5d9f169268c9e50d3605e8 /nar-herder/database.scm
parent16c616010a0e7e3a000abd951f386ffe1c6d9c6c (diff)
downloadnar-herder-d3d9a365fc9aa09c3d6e4d5b80126976d4b39961.tar
nar-herder-d3d9a365fc9aa09c3d6e4d5b80126976d4b39961.tar.gz
Don't error when removing files that don't exist
This is useful when removing in bulk and restarting the process.
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