@@ -557,7 +557,7 @@ pub(crate) struct DocumentInfo {
557
557
change_observers : Vec < RepoFutureResolver < Result < ( ) , RepoError > > > ,
558
558
/// Counter of local saves since last compact,
559
559
/// used to make decisions about full or incemental saves.
560
- saves_since_last_compact : usize ,
560
+ patches_since_last_compact : usize ,
561
561
///
562
562
allowable_changes_until_compaction : usize ,
563
563
/// Last heads obtained from the automerge doc.
@@ -580,7 +580,7 @@ impl DocumentInfo {
580
580
handle_count,
581
581
sync_states : Default :: default ( ) ,
582
582
change_observers : Default :: default ( ) ,
583
- saves_since_last_compact : 0 ,
583
+ patches_since_last_compact : 0 ,
584
584
allowable_changes_until_compaction : 10 ,
585
585
last_heads,
586
586
}
@@ -600,7 +600,7 @@ impl DocumentInfo {
600
600
| DocState :: Error
601
601
| DocState :: LoadPending { .. }
602
602
| DocState :: Bootstrap { .. } => {
603
- assert_eq ! ( self . saves_since_last_compact , 0 ) ;
603
+ assert_eq ! ( self . patches_since_last_compact , 0 ) ;
604
604
DocState :: PendingRemoval ( vec ! [ ] )
605
605
}
606
606
DocState :: Sync ( ref mut storage_fut) => DocState :: PendingRemoval ( mem:: take ( storage_fut) ) ,
@@ -704,14 +704,18 @@ impl DocumentInfo {
704
704
let count = {
705
705
let doc = self . document . read ( ) ;
706
706
let changes = doc. automerge . get_changes ( & self . last_heads ) ;
707
- println ! ( "last: {:?}, current: {:?}" , self . last_heads, doc. automerge. get_heads( ) ) ;
707
+ println ! (
708
+ "last: {:?}, current: {:?}" ,
709
+ self . last_heads,
710
+ doc. automerge. get_heads( )
711
+ ) ;
708
712
//self.last_heads = doc.automerge.get_heads();
709
713
changes. len ( )
710
714
} ;
711
715
let has_patches = count > 0 ;
712
716
println ! ( "Has patches: {:?}" , has_patches) ;
713
- self . saves_since_last_compact = self
714
- . saves_since_last_compact
717
+ self . patches_since_last_compact = self
718
+ . patches_since_last_compact
715
719
. checked_add ( count)
716
720
. unwrap_or ( 0 ) ;
717
721
has_patches
@@ -735,14 +739,14 @@ impl DocumentInfo {
735
739
return ;
736
740
}
737
741
let should_compact =
738
- self . saves_since_last_compact > self . allowable_changes_until_compaction ;
742
+ self . patches_since_last_compact > self . allowable_changes_until_compaction ;
739
743
let ( storage_fut, new_heads) = if should_compact {
740
744
println ! ( "We decided to Compact the document" ) ;
741
745
let ( to_save, new_heads) = {
742
746
let doc = self . document . read ( ) ;
743
747
( doc. automerge . save ( ) , doc. automerge . get_heads ( ) )
744
748
} ;
745
- self . saves_since_last_compact = 0 ;
749
+ self . patches_since_last_compact = 0 ;
746
750
println ! ( "Since compact is zero" ) ;
747
751
( storage. compact ( document_id. clone ( ) , to_save) , new_heads)
748
752
} else {
@@ -754,8 +758,11 @@ impl DocumentInfo {
754
758
doc. automerge . get_heads ( ) ,
755
759
)
756
760
} ;
757
- self . saves_since_last_compact . checked_add ( 1 ) . unwrap_or ( 0 ) ;
758
- println ! ( "Saves since last compact {}" , self . saves_since_last_compact) ;
761
+ self . patches_since_last_compact . checked_add ( 1 ) . unwrap_or ( 0 ) ;
762
+ println ! (
763
+ "Saves since last compact {}" ,
764
+ self . patches_since_last_compact
765
+ ) ;
759
766
( storage. append ( document_id. clone ( ) , to_save) , new_heads)
760
767
} ;
761
768
match self . state {
0 commit comments