mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-30 12:01:57 +00:00
allow empty commit without revision
This commit is contained in:
committed by
Aiden McClelland
parent
c3e28cb683
commit
932a5741e6
@@ -27,7 +27,13 @@ pub struct Transaction<Parent: DbHandle> {
|
|||||||
pub(crate) sub: Receiver<Arc<Revision>>,
|
pub(crate) sub: Receiver<Arc<Revision>>,
|
||||||
}
|
}
|
||||||
impl Transaction<&mut PatchDbHandle> {
|
impl Transaction<&mut PatchDbHandle> {
|
||||||
pub async fn commit(mut self, expire_id: Option<String>) -> Result<Arc<Revision>, Error> {
|
pub async fn commit(
|
||||||
|
mut self,
|
||||||
|
expire_id: Option<String>,
|
||||||
|
) -> Result<Option<Arc<Revision>>, Error> {
|
||||||
|
if (self.updates.0).0.is_empty() && expire_id.is_none() {
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
let store_lock = self.parent.store();
|
let store_lock = self.parent.store();
|
||||||
let store = store_lock.write().await;
|
let store = store_lock.write().await;
|
||||||
self.rebase()?;
|
self.rebase()?;
|
||||||
@@ -36,7 +42,8 @@ impl Transaction<&mut PatchDbHandle> {
|
|||||||
.db
|
.db
|
||||||
.apply(self.updates, expire_id, Some(store))
|
.apply(self.updates, expire_id, Some(store))
|
||||||
.await?;
|
.await?;
|
||||||
Ok(rev)
|
Ok(Some(rev))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub async fn abort(mut self) -> Result<DiffPatch, Error> {
|
pub async fn abort(mut self) -> Result<DiffPatch, Error> {
|
||||||
let store_lock = self.parent.store();
|
let store_lock = self.parent.store();
|
||||||
|
|||||||
Reference in New Issue
Block a user