aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mail/incoming.rs6
-rw-r--r--src/mail/user.rs2
-rw-r--r--src/storage/garage.rs2
-rw-r--r--src/storage/in_memory.rs2
-rw-r--r--src/storage/mod.rs3
5 files changed, 8 insertions, 7 deletions
diff --git a/src/mail/incoming.rs b/src/mail/incoming.rs
index db22f3e..da4c819 100644
--- a/src/mail/incoming.rs
+++ b/src/mail/incoming.rs
@@ -77,7 +77,7 @@ async fn incoming_mail_watch_process_internal(
tokio::select! {
inc_k = wait_new_mail => Some(inc_k),
- _ = tokio::time::sleep(MAIL_CHECK_INTERVAL) => Some(k2v.from_orphan(incoming_key.to_orphan())),
+ _ = tokio::time::sleep(MAIL_CHECK_INTERVAL) => Some(k2v.from_orphan(incoming_key.to_orphan()).expect("Incompatible source & target storage")),
_ = lock_held.changed() => None,
_ = rx_inbox_id.changed() => None,
}
@@ -358,7 +358,7 @@ async fn k2v_lock_loop_internal(
));
lock[8..].copy_from_slice(&our_pid.0);
let row = match ct {
- Some(orphan) => k2v.from_orphan(orphan),
+ Some(orphan) => k2v.from_orphan(orphan).expect("Source & target must be storage compatible"),
None => k2v.row(pk, sk),
};
if let Err(e) = row.set_value(lock).push().await {
@@ -387,7 +387,7 @@ async fn k2v_lock_loop_internal(
_ => None,
};
if let Some(ct) = release {
- let row = k2v.from_orphan(ct);
+ let row = k2v.from_orphan(ct).expect("Incompatible source & target storage");
let _ = row.rm().await;
}
}
diff --git a/src/mail/user.rs b/src/mail/user.rs
index 7011dcc..7a3e5c7 100644
--- a/src/mail/user.rs
+++ b/src/mail/user.rs
@@ -306,7 +306,7 @@ impl User {
) -> Result<()> {
let list_blob = seal_serialize(list, &self.creds.keys.master)?;
let rref = match ct {
- Some(x) => self.k2v.from_orphan(x),
+ Some(x) => self.k2v.from_orphan(x).expect("Source & target must be same storage"),
None => self.k2v.row(MAILBOX_LIST_PK, MAILBOX_LIST_SK),
};
rref.set_value(list_blob).push().await?;
diff --git a/src/storage/garage.rs b/src/storage/garage.rs
index f458aeb..00962f2 100644
--- a/src/storage/garage.rs
+++ b/src/storage/garage.rs
@@ -36,7 +36,7 @@ impl IRowStore for GrgStore {
unimplemented!();
}
- fn from_orphan(&self, orphan: OrphanRowRef) -> RowRef {
+ fn from_orphan(&self, orphan: OrphanRowRef) -> Result<RowRef, StorageError> {
unimplemented!();
}
}
diff --git a/src/storage/in_memory.rs b/src/storage/in_memory.rs
index 20f96a4..a29b790 100644
--- a/src/storage/in_memory.rs
+++ b/src/storage/in_memory.rs
@@ -37,7 +37,7 @@ impl IRowStore for MemStore {
unimplemented!();
}
- fn from_orphan(&self, orphan: OrphanRowRef) -> RowRef {
+ fn from_orphan(&self, orphan: OrphanRowRef) -> Result<RowRef, StorageError> {
unimplemented!();
}
}
diff --git a/src/storage/mod.rs b/src/storage/mod.rs
index 08ccfec..86d7fa2 100644
--- a/src/storage/mod.rs
+++ b/src/storage/mod.rs
@@ -36,6 +36,7 @@ pub enum Selector<'a> {
pub enum StorageError {
NotFound,
Internal,
+ IncompatibleOrphan,
}
impl std::fmt::Display for StorageError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -87,7 +88,7 @@ pub trait IRowStore
fn row(&self, partition: &str, sort: &str) -> RowRef;
fn select(&self, selector: Selector) -> AsyncResult<Vec<RowValue>>;
fn rm(&self, selector: Selector) -> AsyncResult<()>;
- fn from_orphan(&self, orphan: OrphanRowRef) -> RowRef;
+ fn from_orphan(&self, orphan: OrphanRowRef) -> Result<RowRef, StorageError>;
}
pub type RowStore = Box<dyn IRowStore + Sync + Send>;