mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +03:00
cargo fmt
This commit is contained in:
26
src/imex.rs
26
src/imex.rs
@@ -1,6 +1,6 @@
|
|||||||
use core::cmp::{min,max};
|
use core::cmp::{max, min};
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::path::{Path,PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
@@ -596,7 +596,9 @@ fn export_backup(context: &Context, dir: impl AsRef<Path>) -> Result<()> {
|
|||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
Ok(()) => {
|
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()));
|
context.call_cb(Event::ImexFileWritten(dest_path_filename.clone()));
|
||||||
Ok(())
|
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
|
// 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)
|
// the source to be locked, neigher the destination as it is used only here)
|
||||||
let sql = Sql::new();
|
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") {
|
if !sql.table_exists("backup_blobs") {
|
||||||
sql::execute(
|
sql::execute(
|
||||||
context,
|
context,
|
||||||
@@ -641,22 +646,17 @@ fn add_files_to_export(context: &Context, dest_path_filename: &PathBuf) -> Resul
|
|||||||
bail!("canceled during export-files");
|
bail!("canceled during export-files");
|
||||||
}
|
}
|
||||||
processed_files_cnt += 1;
|
processed_files_cnt += 1;
|
||||||
let permille = max(min(
|
let permille = max(min(processed_files_cnt * 1000 / total_files_cnt, 990), 10);
|
||||||
processed_files_cnt * 1000 / total_files_cnt,
|
|
||||||
990), 10);
|
|
||||||
context.call_cb(Event::ImexProgress(permille));
|
context.call_cb(Event::ImexProgress(permille));
|
||||||
|
|
||||||
let name_f = entry.file_name();
|
let name_f = entry.file_name();
|
||||||
let name = name_f.to_string_lossy();
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
info!(context, "EXPORT: copying filename={}", name);
|
info!(context, "EXPORT: copying filename={}", name);
|
||||||
let curr_path_filename = context.get_blobdir().join(entry.file_name());
|
let curr_path_filename = context.get_blobdir().join(entry.file_name());
|
||||||
if let Ok(buf) =
|
if let Ok(buf) = dc_read_file(context, &curr_path_filename) {
|
||||||
dc_read_file(context, &curr_path_filename)
|
|
||||||
{
|
|
||||||
if buf.is_empty() {
|
if buf.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -665,7 +665,7 @@ fn add_files_to_export(context: &Context, dest_path_filename: &PathBuf) -> Resul
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
},
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user