@@ -43,20 +43,15 @@ impl Restore {
4343 let snapshot_path = snapshots_dir. join ( & self . snapshot ) ;
4444
4545 if !snapshot_path. exists ( ) {
46- return Err ( anyhow ! (
47- "Snapshot '{}' not found at '{}'" ,
48- self . snapshot,
49- snapshot_path. display( )
50- ) ) ;
46+ return Err ( anyhow ! ( "Snapshot '{}' not found at '{}'" , self . snapshot, snapshot_path. display( ) ) ) ;
5147 }
5248
5349 // Clear the current storage directory, preserving the directory itself.
5450 if self . storage . exists ( ) {
5551 println ! ( "Clearing storage directory: {}" , self . storage. display( ) ) ;
5652 clear_dir ( & self . storage ) ?;
5753 } else {
58- std:: fs:: create_dir_all ( & self . storage )
59- . map_err ( |e| anyhow ! ( "Failed to create storage directory: {e}" ) ) ?;
54+ std:: fs:: create_dir_all ( & self . storage ) . map_err ( |e| anyhow ! ( "Failed to create storage directory: {e}" ) ) ?;
6055 }
6156
6257 // Copy the snapshot into the storage directory.
@@ -65,12 +60,15 @@ impl Restore {
6560 println ! ( "Restore complete." ) ;
6661
6762 if self . restart {
68- relaunch_as_start ( & self . storage , self . private_key . as_deref ( ) , & self . socket_addr , self . verbosity , self . manual_block_creation ) ?;
63+ relaunch_as_start (
64+ & self . storage ,
65+ self . private_key . as_deref ( ) ,
66+ & self . socket_addr ,
67+ self . verbosity ,
68+ self . manual_block_creation ,
69+ ) ?;
6970 } else {
70- println ! (
71- "Restart the devnode with:\n aleo-devnode start --storage {}" ,
72- self . storage. display( )
73- ) ;
71+ println ! ( "Restart the devnode with:\n aleo-devnode start --storage {}" , self . storage. display( ) ) ;
7472 }
7573
7674 Ok ( ( ) )
@@ -130,10 +128,7 @@ fn relaunch_as_start(
130128/// Returns the snapshots directory that sits alongside the given storage directory.
131129/// e.g. `devnode` → `devnode-snapshots`
132130pub ( crate ) fn snapshots_sibling_dir ( storage : & Path ) -> PathBuf {
133- let dir_name = format ! (
134- "{}-snapshots" ,
135- storage. file_name( ) . unwrap_or_default( ) . to_string_lossy( )
136- ) ;
131+ let dir_name = format ! ( "{}-snapshots" , storage. file_name( ) . unwrap_or_default( ) . to_string_lossy( ) ) ;
137132 let mut p = storage. to_path_buf ( ) ;
138133 p. pop ( ) ;
139134 p. join ( dir_name)
@@ -144,11 +139,9 @@ fn clear_dir(dir: &Path) -> Result<()> {
144139 let entry = entry. map_err ( |e| anyhow ! ( "Failed to read entry: {e}" ) ) ?;
145140 let path = entry. path ( ) ;
146141 if path. is_dir ( ) {
147- std:: fs:: remove_dir_all ( & path)
148- . map_err ( |e| anyhow ! ( "Failed to remove '{}': {e}" , path. display( ) ) ) ?;
142+ std:: fs:: remove_dir_all ( & path) . map_err ( |e| anyhow ! ( "Failed to remove '{}': {e}" , path. display( ) ) ) ?;
149143 } else {
150- std:: fs:: remove_file ( & path)
151- . map_err ( |e| anyhow ! ( "Failed to remove '{}': {e}" , path. display( ) ) ) ?;
144+ std:: fs:: remove_file ( & path) . map_err ( |e| anyhow ! ( "Failed to remove '{}': {e}" , path. display( ) ) ) ?;
152145 }
153146 }
154147 Ok ( ( ) )
@@ -163,8 +156,7 @@ fn copy_dir_all(src: &Path, dst: &Path) -> Result<()> {
163156 if src_path. is_dir ( ) {
164157 copy_dir_all ( & src_path, & dst_path) ?;
165158 } else {
166- std:: fs:: copy ( & src_path, & dst_path)
167- . map_err ( |e| anyhow ! ( "Failed to copy '{}': {e}" , src_path. display( ) ) ) ?;
159+ std:: fs:: copy ( & src_path, & dst_path) . map_err ( |e| anyhow ! ( "Failed to copy '{}': {e}" , src_path. display( ) ) ) ?;
168160 }
169161 }
170162 Ok ( ( ) )
0 commit comments