diff --git a/src/ssb.db.c b/src/ssb.db.c index 5b0c343e..31202b11 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -448,8 +448,6 @@ bool tf_ssb_db_blob_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_ bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* out_id, size_t out_id_size, bool* out_new) { bool result = false; - sqlite3* db = tf_ssb_acquire_db_writer(ssb); - sqlite3_stmt* statement; uint8_t hash[crypto_hash_sha256_BYTES]; crypto_hash_sha256(hash, blob, size); @@ -462,6 +460,8 @@ bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* int rows = 0; + sqlite3* db = tf_ssb_acquire_db_writer(ssb); + sqlite3_stmt* statement; if (sqlite3_prepare(db, "INSERT INTO blobs (id, content, created) VALUES ($1, $2, CAST(strftime('%s') AS INTEGER)) ON CONFLICT DO NOTHING", -1, &statement, NULL) == SQLITE_OK) { if (sqlite3_bind_text(statement, 1, id, -1, NULL) == SQLITE_OK &&