mirror of
https://github.com/chatmail/core.git
synced 2026-05-24 09:16:32 +03:00
cargo fmt
This commit is contained in:
24
src/imex.rs
24
src/imex.rs
@@ -1,4 +1,4 @@
|
||||
use core::cmp::{min,max};
|
||||
use core::cmp::{max, min};
|
||||
use std::ffi::CString;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::ptr;
|
||||
@@ -596,7 +596,9 @@ fn export_backup(context: &Context, dir: impl AsRef<Path>) -> Result<()> {
|
||||
Err(err)
|
||||
}
|
||||
Ok(()) => {
|
||||
context.sql.set_raw_config_int(context, "backup_time", now as i32)?;
|
||||
context
|
||||
.sql
|
||||
.set_raw_config_int(context, "backup_time", now as i32)?;
|
||||
context.call_cb(Event::ImexFileWritten(dest_path_filename.clone()));
|
||||
Ok(())
|
||||
}
|
||||
@@ -607,7 +609,10 @@ fn add_files_to_export(context: &Context, dest_path_filename: &PathBuf) -> Resul
|
||||
// add all files as blobs to the database copy (this does not require
|
||||
// the source to be locked, neigher the destination as it is used only here)
|
||||
let sql = Sql::new();
|
||||
ensure!(sql.open(context, &dest_path_filename, 0), "could not open db");
|
||||
ensure!(
|
||||
sql.open(context, &dest_path_filename, 0),
|
||||
"could not open db"
|
||||
);
|
||||
if !sql.table_exists("backup_blobs") {
|
||||
sql::execute(
|
||||
context,
|
||||
@@ -641,22 +646,17 @@ fn add_files_to_export(context: &Context, dest_path_filename: &PathBuf) -> Resul
|
||||
bail!("canceled during export-files");
|
||||
}
|
||||
processed_files_cnt += 1;
|
||||
let permille = max(min(
|
||||
processed_files_cnt * 1000 / total_files_cnt,
|
||||
990), 10);
|
||||
let permille = max(min(processed_files_cnt * 1000 / total_files_cnt, 990), 10);
|
||||
context.call_cb(Event::ImexProgress(permille));
|
||||
|
||||
let name_f = entry.file_name();
|
||||
let name = name_f.to_string_lossy();
|
||||
if name.starts_with("delta-chat") && name.ends_with(".bak")
|
||||
{
|
||||
if name.starts_with("delta-chat") && name.ends_with(".bak") {
|
||||
continue;
|
||||
}
|
||||
info!(context, "EXPORT: copying filename={}", name);
|
||||
let curr_path_filename = context.get_blobdir().join(entry.file_name());
|
||||
if let Ok(buf) =
|
||||
dc_read_file(context, &curr_path_filename)
|
||||
{
|
||||
if let Ok(buf) = dc_read_file(context, &curr_path_filename) {
|
||||
if buf.is_empty() {
|
||||
continue;
|
||||
}
|
||||
@@ -665,7 +665,7 @@ fn add_files_to_export(context: &Context, dest_path_filename: &PathBuf) -> Resul
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
},
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user