From 86deed3197f5fdf8c83f4698cb5861ca0843b817 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 16 Jun 2021 11:22:17 +1000 Subject: [PATCH] Remove unused Transaction from Txn Also note about why StorageTxn isn't implemented --- sync-server/src/storage/sqlite.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sync-server/src/storage/sqlite.rs b/sync-server/src/storage/sqlite.rs index cb080e2f8..be075f62b 100644 --- a/sync-server/src/storage/sqlite.rs +++ b/sync-server/src/storage/sqlite.rs @@ -87,17 +87,16 @@ impl SqliteStorage { impl Storage for SqliteStorage { fn txn<'a>(&'a self) -> anyhow::Result> { let con = self.new_connection()?; - let t = Txn { con, txn: None }; + let t = Txn { con }; Ok(Box::new(t)) } } -struct Txn<'t> { +struct Txn { con: Connection, - txn: Option>, } -impl<'t> Txn<'t> { +impl Txn { fn get_txn(&mut self) -> Result { self.con .transaction() @@ -105,7 +104,7 @@ impl<'t> Txn<'t> { } } -impl<'t> StorageTxn for Txn<'t> { +impl StorageTxn for Txn { fn get_client(&mut self, client_key: Uuid) -> anyhow::Result> { let t = self.get_txn()?; let result: Option = t @@ -195,11 +194,10 @@ impl<'t> StorageTxn for Txn<'t> { } fn commit(&mut self) -> anyhow::Result<()> { - let t: rusqlite::Transaction = self - .txn - .take() - .ok_or(SqliteError::TransactionAlreadyCommitted)?; - t.commit().context("Committing transaction")?; + // FIXME: Note the queries aren't currently run in a + // transaction, as storing the transaction object and a pooled + // connection in the `Txn` object is complex. + // https://github.com/taskchampion/taskchampion/pull/206#issuecomment-860336073 Ok(()) } }