From 71d04421bf583b98db1027096435f7f86165810b Mon Sep 17 00:00:00 2001 From: Irene Diez Date: Tue, 14 Nov 2023 11:33:11 +0100 Subject: [PATCH] fix(store): rendezvous store_data stored item Signed-off-by: Irene Diez --- store/src/db.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/store/src/db.rs b/store/src/db.rs index 976393bb4..07af4cfb2 100644 --- a/store/src/db.rs +++ b/store/src/db.rs @@ -1,5 +1,6 @@ use async_trait::async_trait; use fdo_data_formats::ownershipvoucher::OwnershipVoucher; +use fdo_data_formats::StoredItem; use fdo_db::*; use std::marker::PhantomData; @@ -457,17 +458,18 @@ where Err(StoreError::MethodNotAvailable) } - async fn store_data(&self, _key: K, value: V) -> Result<(), StoreError> { + async fn store_data(&self, key: K, value: V) -> Result<(), StoreError> { let pool = fdo_db::sqlite::SqliteRendezvousDB::get_conn_pool(); let conn = &mut pool.get().expect("Couldn't establish a connection"); let raw = V::serialize_data(&value).expect("Error serializing data"); - let ov = OwnershipVoucher::from_pem_or_raw(&raw).expect("Error converting OV"); - fdo_db::sqlite::SqliteRendezvousDB::insert_ov(&ov, None, conn).map_err(|e| { - StoreError::Database(format!( - "Error inserting OV with guid {}: {e:?}", - ov.header().guid().to_string() - )) - }) + let stored = StoredItem::deserialize_data(&raw).expect("Error converting StoredItem"); + fdo_db::sqlite::SqliteRendezvousDB::insert_ov(&stored, &key.to_string(), None, conn) + .map_err(|e| { + StoreError::Database(format!( + "Error inserting StoredItem with guid {}: {e:?}", + &key.to_string() + )) + }) } async fn destroy_data(&self, key: &K) -> Result<(), StoreError> {