This repository was archived by the owner on Oct 23, 2022. It is now read-only.
File tree 1 file changed +12
-3
lines changed 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ pub fn init(
63
63
) -> Result < String , InitializationError > {
64
64
use multibase:: Base :: Base64Pad ;
65
65
use prost:: Message ;
66
- use std:: io:: BufWriter ;
66
+ use std:: fs:: OpenOptions ;
67
+ use std:: io:: { BufWriter , Write } ;
67
68
68
69
if profiles. len ( ) != 1 {
69
70
unimplemented ! ( "Multiple profiles are currently unsupported!" )
@@ -135,12 +136,20 @@ pub fn init(
135
136
let config_file = fs:: create_dir_all ( & ipfs_path)
136
137
. map_err ( InitializationError :: DirectoryCreationFailed )
137
138
. and_then ( |_| {
138
- fs:: File :: create ( & config_path) . map_err ( InitializationError :: ConfigCreationFailed )
139
+ OpenOptions :: new ( )
140
+ . write ( true )
141
+ . create_new ( true )
142
+ . open ( & config_path)
143
+ . map_err ( InitializationError :: ConfigCreationFailed )
139
144
} ) ?;
140
145
141
- serde_json:: to_writer_pretty ( BufWriter :: new ( config_file) , & config_contents)
146
+ let mut writer = BufWriter :: new ( config_file) ;
147
+
148
+ serde_json:: to_writer_pretty ( & mut writer, & config_contents)
142
149
. map_err ( InitializationError :: ConfigWritingFailed ) ?;
143
150
151
+ writer. flush ( ) . unwrap ( ) ;
152
+
144
153
Ok ( peer_id)
145
154
}
146
155
You can’t perform that action at this time.
0 commit comments