@@ -607,7 +607,9 @@ impl Replicator {
607
607
return Ok ( ( ) ) ;
608
608
}
609
609
tracing:: debug!( "Snapshotting {}" , self . db_path) ;
610
- let change_counter = match self . use_compression {
610
+
611
+ let mut reader = tokio:: fs:: File :: open ( & self . db_path ) . await ?;
612
+ match self . use_compression {
611
613
CompressionKind :: None => {
612
614
self . client
613
615
. put_object ( )
@@ -616,11 +618,8 @@ impl Replicator {
616
618
. body ( ByteStream :: from_path ( & self . db_path ) . await ?)
617
619
. send ( )
618
620
. await ?;
619
- let mut reader = tokio:: fs:: File :: open ( & self . db_path ) . await ?;
620
- Self :: read_change_counter ( & mut reader) . await ?
621
621
}
622
622
CompressionKind :: Gzip => {
623
- let mut reader = tokio:: fs:: File :: open ( & self . db_path ) . await ?;
624
623
let buf_reader = tokio:: io:: BufReader :: new ( reader. try_clone ( ) . await ?) ;
625
624
let gzip_reader = async_compression:: tokio:: bufread:: GzipEncoder :: new ( buf_reader) ;
626
625
@@ -630,8 +629,6 @@ impl Replicator {
630
629
// the whole snapshot in memory because S3 requires the `Content-Length` header
631
630
// to be set.
632
631
upload_s3_multipart ( & self . client , & key, & self . bucket , gzip_reader) . await ?;
633
-
634
- Self :: read_change_counter ( & mut reader) . await ?
635
632
}
636
633
} ;
637
634
@@ -641,6 +638,7 @@ impl Replicator {
641
638
** incremented on each transaction in WAL mode."
642
639
** Instead, we need to consult WAL checksums.
643
640
*/
641
+ let change_counter = Self :: read_change_counter ( & mut reader) . await ?;
644
642
let change_counter_key = format ! ( "{}-{}/.changecounter" , self . db_name, self . generation) ;
645
643
self . client
646
644
. put_object ( )
0 commit comments