@@ -2,6 +2,7 @@ extern crate dirs;
2
2
3
3
use std:: path:: Path ;
4
4
use std:: str:: FromStr ;
5
+ use std:: time:: { Duration , SystemTime } ;
5
6
6
7
use anyhow:: { bail, ensure, Result } ;
7
8
use deltachat:: chat:: {
@@ -22,8 +23,7 @@ use deltachat::peerstate::*;
22
23
use deltachat:: qr:: * ;
23
24
use deltachat:: sql;
24
25
use deltachat:: { config, provider} ;
25
- use std:: fs;
26
- use std:: time:: { Duration , SystemTime } ;
26
+ use tokio:: fs;
27
27
28
28
/// Reset database tables.
29
29
/// Argument is a bitmask, executing single or multiple actions in one call.
@@ -135,17 +135,13 @@ async fn poke_spec(context: &Context, spec: Option<&str>) -> bool {
135
135
} else {
136
136
/* import a directory */
137
137
let dir_name = std:: path:: Path :: new ( & real_spec) ;
138
- let dir = std :: fs:: read_dir ( dir_name) ;
138
+ let dir = fs:: read_dir ( dir_name) . await ;
139
139
if dir. is_err ( ) {
140
140
error ! ( context, "Import: Cannot open directory \" {}\" ." , & real_spec, ) ;
141
141
return false ;
142
142
} else {
143
- let dir = dir. unwrap ( ) ;
144
- for entry in dir {
145
- if entry. is_err ( ) {
146
- break ;
147
- }
148
- let entry = entry. unwrap ( ) ;
143
+ let mut dir = dir. unwrap ( ) ;
144
+ while let Ok ( Some ( entry) ) = dir. next_entry ( ) . await {
149
145
let name_f = entry. file_name ( ) ;
150
146
let name = name_f. to_string_lossy ( ) ;
151
147
if name. ends_with ( ".eml" ) {
@@ -492,7 +488,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
492
488
let setup_code = create_setup_code ( & context) ;
493
489
let file_name = blobdir. join ( "autocrypt-setup-message.html" ) ;
494
490
let file_content = render_setup_file ( & context, & setup_code) . await ?;
495
- tokio :: fs:: write ( & file_name, file_content) . await ?;
491
+ fs:: write ( & file_name, file_content) . await ?;
496
492
println ! (
497
493
"Setup message written to: {}\n Setup code: {}" ,
498
494
file_name. display( ) ,
@@ -532,7 +528,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
532
528
. join ( "connectivity.html" ) ;
533
529
match context. get_connectivity_html ( ) . await {
534
530
Ok ( html) => {
535
- fs:: write ( & file, html) ?;
531
+ fs:: write ( & file, html) . await ?;
536
532
println ! ( "Report written to: {:#?}" , file) ;
537
533
}
538
534
Err ( err) => {
@@ -892,7 +888,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
892
888
ensure ! ( sel_chat. is_some( ) , "No chat selected." ) ;
893
889
ensure ! ( !arg1. is_empty( ) , "No html-file given." ) ;
894
890
let path: & Path = arg1. as_ref ( ) ;
895
- let html = & * fs:: read ( & path) ?;
891
+ let html = & * fs:: read ( & path) . await ?;
896
892
let html = String :: from_utf8_lossy ( html) ;
897
893
898
894
let mut msg = Message :: new ( Viewtype :: Text ) ;
@@ -1079,7 +1075,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
1079
1075
. unwrap_or_default ( )
1080
1076
. join ( format ! ( "msg-{}.html" , id. to_u32( ) ) ) ;
1081
1077
let html = id. get_html ( & context) . await ?. unwrap_or_default ( ) ;
1082
- fs:: write ( & file, html) ?;
1078
+ fs:: write ( & file, html) . await ?;
1083
1079
println ! ( "HTML written to: {:#?}" , file) ;
1084
1080
}
1085
1081
"listfresh" => {
0 commit comments