From 925b3e254c6488c2609565c4995843a0c20df7c5 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 3 Jun 2022 23:10:37 +0000 Subject: [PATCH] imex: do not remove our database if backup cannot be imported We may still want to try importing another backup into the same database. --- src/imex.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/imex.rs b/src/imex.rs index 5b0021fb3..fd304f18c 100644 --- a/src/imex.rs +++ b/src/imex.rs @@ -19,8 +19,8 @@ use crate::config::Config; use crate::contact::ContactId; use crate::context::Context; use crate::dc_tools::{ - dc_create_folder, dc_delete_file, dc_delete_files_in_dir, dc_get_filesuffix_lc, - dc_open_file_std, dc_read_file, dc_write_file, time, EmailAddress, + dc_create_folder, dc_delete_file, dc_get_filesuffix_lc, dc_open_file_std, dc_read_file, + dc_write_file, time, EmailAddress, }; use crate::e2ee; use crate::events::EventType; @@ -95,7 +95,6 @@ pub async fn imex( Ok(()) } Err(err) => { - cleanup_aborted_imex(context, what).await; // We are using Anyhow's .context() and to show the inner error, too, we need the {:#}: error!(context, "{:#}", err); context.emit_event(EventType::ImexProgress(0)); @@ -105,7 +104,6 @@ pub async fn imex( } .race(async { cancel.recv().await.ok(); - cleanup_aborted_imex(context, what).await; Err(format_err!("canceled")) }) .await; @@ -115,13 +113,6 @@ pub async fn imex( res } -async fn cleanup_aborted_imex(context: &Context, what: ImexMode) { - if what == ImexMode::ImportBackup { - dc_delete_file(context, context.get_dbfile()).await; - dc_delete_files_in_dir(context, context.get_blobdir()).await; - } -} - /// Returns the filename of the backup found (otherwise an error) pub async fn has_backup(_context: &Context, dir_name: &Path) -> Result { let mut dir_iter = async_std::fs::read_dir(dir_name).await?;