mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-02 02:59:51 +00:00
fix: should not use snapshot importing when it's inside a batch importing (#436)
* fix: should not use snapshot importing when it's inside a batch importing * chore: bk
This commit is contained in:
parent
c36664e784
commit
7cf54e8aa3
5 changed files with 27 additions and 2 deletions
6
.changeset/strong-walls-vanish.md
Normal file
6
.changeset/strong-walls-vanish.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
"loro-wasm": patch
|
||||
"loro-crdt": patch
|
||||
---
|
||||
|
||||
Fix batch importing with snapshot
|
|
@ -216,7 +216,12 @@ impl LoroDoc {
|
|||
/// Is the document empty? (no ops)
|
||||
#[inline(always)]
|
||||
pub fn can_reset_with_snapshot(&self) -> bool {
|
||||
self.oplog.lock().unwrap().is_empty() && self.state.lock().unwrap().is_empty()
|
||||
let oplog = self.oplog.lock().unwrap();
|
||||
if oplog.batch_importing {
|
||||
return false;
|
||||
}
|
||||
|
||||
oplog.is_empty() && self.state.lock().unwrap().is_empty()
|
||||
}
|
||||
|
||||
/// Whether [OpLog] and [DocState] are detached.
|
||||
|
|
|
@ -213,7 +213,7 @@ impl LoroDoc {
|
|||
/// Import a batch of updates/snapshot.
|
||||
///
|
||||
/// The data can be in arbitrary order. The import result will be the same.
|
||||
pub fn import_batch(&mut self, bytes: &[Vec<u8>]) -> LoroResult<()> {
|
||||
pub fn import_batch(&self, bytes: &[Vec<u8>]) -> LoroResult<()> {
|
||||
self.doc.import_batch(bytes)
|
||||
}
|
||||
|
||||
|
|
14
crates/loro/tests/issue.rs
Normal file
14
crates/loro/tests/issue.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use loro::LoroDoc;
|
||||
|
||||
#[ctor::ctor]
|
||||
fn init() {
|
||||
dev_utils::setup_test_log();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_0() {
|
||||
let bytes = include_bytes!("./issue_0.bin");
|
||||
let doc = LoroDoc::new();
|
||||
doc.import_batch(&[bytes.into()]).unwrap();
|
||||
doc.export_snapshot();
|
||||
}
|
BIN
crates/loro/tests/issue_0.bin
Normal file
BIN
crates/loro/tests/issue_0.bin
Normal file
Binary file not shown.
Loading…
Reference in a new issue