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
This commit is contained in:
Hocuri
2021-01-16 15:49:46 +01:00
parent b505d2666b
commit 35b0f00a88
2 changed files with 10 additions and 4 deletions

View File

@@ -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();

View File

@@ -179,10 +179,15 @@ pub async fn has_backup_old(context: &Context, dir_name: impl AsRef<Path>) -> 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
}
}
}
}
}