File tree Expand file tree Collapse file tree 1 file changed +26
-15
lines changed Expand file tree Collapse file tree 1 file changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -149,22 +149,33 @@ impl Args {
149
149
args. rpc_password . as_ref ( ) . unwrap ( ) ,
150
150
)
151
151
} else {
152
- let cookie = format ! (
153
- "__cookie__:{}" ,
154
- thread_rng( )
155
- . sample_iter( & Alphanumeric )
156
- . take( 64 )
157
- . map( char :: from)
158
- . collect:: <String >( )
159
- ) ;
160
152
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
- } ) ?;
153
+ let cookie = if cookie_path. exists ( ) {
154
+ fs:: read_to_string ( & cookie_path) . map_err ( |e| {
155
+ anyhow ! (
156
+ "Failed to read cookie file '{}': {}" ,
157
+ cookie_path. display( ) ,
158
+ e
159
+ )
160
+ } ) ?
161
+ } else {
162
+ let cookie = format ! (
163
+ "__cookie__:{}" ,
164
+ thread_rng( )
165
+ . sample_iter( & Alphanumeric )
166
+ . take( 64 )
167
+ . map( char :: from)
168
+ . collect:: <String >( )
169
+ ) ;
170
+ fs:: write ( & cookie_path, & cookie) . map_err ( |e| {
171
+ anyhow ! (
172
+ "Failed to write cookie file '{}': {}" ,
173
+ cookie_path. display( ) ,
174
+ e
175
+ )
176
+ } ) ?;
177
+ cookie
178
+ } ;
168
179
auth_token_from_cookie ( & cookie)
169
180
} ;
170
181
You can’t perform that action at this time.
0 commit comments