File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -220,6 +220,12 @@ impl SnapshotDirPath {
220220 let invalid_path = self . 0 . with_extension ( "invalid_snapshot" ) ;
221221 fs:: rename ( self , invalid_path)
222222 }
223+
224+ pub fn tx_offset ( & self ) -> Option < u64 > {
225+ self . 0
226+ . file_stem ( )
227+ . and_then ( |s| s. to_str ( ) ?. split ( '.' ) . next ( ) ?. parse :: < u64 > ( ) . ok ( ) )
228+ }
223229}
224230
225231path_type ! {
@@ -297,4 +303,14 @@ mod tests {
297303 sdd. pid_file ( ) ?;
298304 Ok ( ( ) )
299305 }
306+
307+ #[ test]
308+ fn test_snapshot_parsing ( ) -> Result < ( ) > {
309+ let tempdir = TempDir :: new ( ) ?;
310+ let sdd = ServerDataDir ( tempdir. path ( ) . to_path_buf ( ) ) ;
311+ const SNAPSHOT_OFFSET : u64 = 123456 ;
312+ let snapshot_dir = sdd. replica ( 1 ) . snapshots ( ) . snapshot_dir ( SNAPSHOT_OFFSET ) ;
313+ assert_eq ! ( Some ( SNAPSHOT_OFFSET ) , snapshot_dir. tx_offset( ) ) ;
314+ Ok ( ( ) )
315+ }
300316}
You can’t perform that action at this time.
0 commit comments