From 35b0f00a88d9af192275e167bb44b02c9bf258de Mon Sep 17 00:00:00 2001 From: Hocuri Date: Sat, 16 Jan 2021 15:49:46 +0100 Subject: [PATCH] legacy (.bak) import: If backup files can't be opened, just try one that couldn't be opened fix https://github.com/deltachat/deltachat-android/issues/1768 --- src/dc_tools.rs | 1 + src/imex.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dc_tools.rs b/src/dc_tools.rs index d1fb38670..7b7ac7207 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -514,6 +514,7 @@ pub(crate) async fn get_next_backup_path( ) -> Result<(PathBuf, PathBuf), Error> { let folder = PathBuf::from(folder.as_ref()); let stem = chrono::NaiveDateTime::from_timestamp(backup_time, 0) + // Don't change this file name format, in has_backup() we use string comparison to determine which backup is newer: .format("delta-chat-backup-%Y-%m-%d") .to_string(); diff --git a/src/imex.rs b/src/imex.rs index 863c83345..ce80e78a9 100644 --- a/src/imex.rs +++ b/src/imex.rs @@ -179,10 +179,15 @@ pub async fn has_backup_old(context: &Context, dir_name: impl AsRef) -> Re info!(context, "backup_time of {} is {}", name, curr_backup_time); sql.close().await; } - Err(e) => warn!( - context, - "Found backup file {} which could not be opened: {}", name, e - ), + Err(e) => { + warn!( + context, + "Found backup file {} which could not be opened: {}", name, e + ); + if newest_backup_path.is_none() { + newest_backup_path = Some(path); // If there is no other backup file, just try this one + } + } } } }