fix: commit txn when dropping

it's less confusing
This commit is contained in:
Zixuan Chen 2023-11-08 14:16:10 +08:00
parent a68482a495
commit 93a52ba55e
No known key found for this signature in database

View file

@ -52,11 +52,18 @@ pub struct LoroDoc {
arena: SharedArena,
observer: Arc<Observer>,
diff_calculator: Arc<Mutex<DiffCalculator>>,
// when dropping the doc, the txn will be commited
txn: Arc<Mutex<Option<Transaction>>>,
auto_commit: bool,
detached: bool,
}
impl Default for LoroDoc {
fn default() -> Self {
Self::new()
}
}
impl LoroDoc {
pub fn new() -> Self {
let oplog = OpLog::new();
@ -664,18 +671,6 @@ fn parse_encode_header(bytes: &[u8]) -> Result<(&[u8], EncodeMode), LoroError> {
Ok((&input[1..], mode))
}
impl Default for LoroDoc {
fn default() -> Self {
Self::new()
}
}
impl Drop for LoroDoc {
fn drop(&mut self) {
self.abort_txn();
}
}
#[cfg(test)]
mod test {
use loro_common::ID;