Fix cancelling imex (#1855)

Fix deltachat/deltachat-android#1579

Also: Make sure that if an error happens, the UI can show the error to the user
This commit is contained in:
Hocuri
2020-08-27 15:02:00 +02:00
committed by GitHub
parent 6eef4066db
commit 927c7eb59d
2 changed files with 62 additions and 20 deletions

View File

@@ -9,7 +9,9 @@ use std::str::FromStr;
use std::time::{Duration, SystemTime};
use async_std::path::{Path, PathBuf};
use async_std::prelude::*;
use async_std::{fs, io};
use chrono::{Local, TimeZone};
use rand::{thread_rng, Rng};
@@ -296,6 +298,23 @@ pub(crate) async fn dc_delete_file(context: &Context, path: impl AsRef<Path>) ->
}
}
pub async fn dc_delete_files_in_dir(context: &Context, path: impl AsRef<Path>) {
match async_std::fs::read_dir(path).await {
Ok(mut read_dir) => {
while let Some(entry) = read_dir.next().await {
match entry {
Ok(file) => {
dc_delete_file(context, file.file_name()).await;
}
Err(e) => warn!(context, "Could not read file to delete: {}", e),
}
}
}
Err(e) => warn!(context, "Could not read dir to delete: {}", e),
}
}
pub(crate) async fn dc_copy_file(
context: &Context,
src_path: impl AsRef<Path>,