@@ -5,15 +5,15 @@ use std::{
5
5
path:: PathBuf ,
6
6
} ;
7
7
8
- use rand:: {
9
- distributions:: Alphanumeric ,
10
- { thread_rng, Rng } ,
11
- } ;
12
-
8
+ use anyhow:: anyhow;
13
9
use clap:: { ArgGroup , Parser , ValueEnum } ;
14
10
use directories:: ProjectDirs ;
15
11
use jsonrpsee:: core:: Serialize ;
16
12
use log:: error;
13
+ use rand:: {
14
+ distributions:: Alphanumeric ,
15
+ { thread_rng, Rng } ,
16
+ } ;
17
17
use serde:: Deserialize ;
18
18
use spaces_protocol:: bitcoin:: Network ;
19
19
@@ -127,6 +127,7 @@ impl Args {
127
127
Some ( data_dir) => data_dir,
128
128
}
129
129
. join ( args. chain . to_string ( ) ) ;
130
+ fs:: create_dir_all ( data_dir. clone ( ) ) ?;
130
131
131
132
let default_port = args. rpc_port . unwrap ( ) ;
132
133
let rpc_bind_addresses: Vec < SocketAddr > = args
@@ -156,7 +157,14 @@ impl Args {
156
157
. map( char :: from)
157
158
. collect:: <String >( )
158
159
) ;
159
- fs:: write ( data_dir. join ( ".cookie" ) , & cookie) ?;
160
+ let cookie_path = data_dir. join ( ".cookie" ) ;
161
+ fs:: write ( & cookie_path, & cookie) . map_err ( |e| {
162
+ anyhow ! (
163
+ "Failed to write cookie file '{}': {}" ,
164
+ cookie_path. display( ) ,
165
+ e
166
+ )
167
+ } ) ?;
160
168
auth_token_from_cookie ( & cookie)
161
169
} ;
162
170
@@ -177,8 +185,6 @@ impl Args {
177
185
178
186
let genesis = Spaced :: genesis ( args. chain ) ;
179
187
180
- fs:: create_dir_all ( data_dir. clone ( ) ) ?;
181
-
182
188
let proto_db_path = data_dir. join ( "protocol.sdb" ) ;
183
189
let initial_sync = !proto_db_path. exists ( ) ;
184
190
0 commit comments