mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +03:00
cargo fmt
This commit is contained in:
100
src/dc_imex.rs
100
src/dc_imex.rs
@@ -587,34 +587,34 @@ unsafe fn export_backup(context: &Context, dir: impl AsRef<Path>) -> Result<()>
|
|||||||
s
|
s
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/* 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) */
|
/* 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) */
|
||||||
/*for logging only*/
|
/*for logging only*/
|
||||||
let sql = Sql::new();
|
let sql = Sql::new();
|
||||||
if sql.open(context, &dest_path_filename, 0) {
|
if sql.open(context, &dest_path_filename, 0) {
|
||||||
if !sql.table_exists("backup_blobs") {
|
if !sql.table_exists("backup_blobs") {
|
||||||
if sql::execute(
|
if sql::execute(
|
||||||
context,
|
context,
|
||||||
&sql,
|
&sql,
|
||||||
"CREATE TABLE backup_blobs (id INTEGER PRIMARY KEY, file_name, file_content);",
|
"CREATE TABLE backup_blobs (id INTEGER PRIMARY KEY, file_name, file_content);",
|
||||||
params![],
|
params![],
|
||||||
)
|
)
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
/* error already logged */
|
/* error already logged */
|
||||||
ok_to_continue = false;
|
ok_to_continue = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ok_to_continue {
|
}
|
||||||
let mut total_files_cnt = 0;
|
if ok_to_continue {
|
||||||
let dir = context.get_blobdir();
|
let mut total_files_cnt = 0;
|
||||||
if let Ok(dir_handle) = std::fs::read_dir(&dir) {
|
let dir = context.get_blobdir();
|
||||||
total_files_cnt += dir_handle.filter(|r| r.is_ok()).count();
|
if let Ok(dir_handle) = std::fs::read_dir(&dir) {
|
||||||
|
total_files_cnt += dir_handle.filter(|r| r.is_ok()).count();
|
||||||
|
|
||||||
info!(context, "EXPORT: total_files_cnt={}", total_files_cnt);
|
info!(context, "EXPORT: total_files_cnt={}", total_files_cnt);
|
||||||
if total_files_cnt > 0 {
|
if total_files_cnt > 0 {
|
||||||
// scan directory, pass 2: copy files
|
// scan directory, pass 2: copy files
|
||||||
if let Ok(dir_handle) = std::fs::read_dir(&dir) {
|
if let Ok(dir_handle) = std::fs::read_dir(&dir) {
|
||||||
sql.prepare(
|
sql.prepare(
|
||||||
"INSERT INTO backup_blobs (file_name, file_content) VALUES (?, ?);",
|
"INSERT INTO backup_blobs (file_name, file_content) VALUES (?, ?);",
|
||||||
move |mut stmt, _| {
|
move |mut stmt, _| {
|
||||||
let mut processed_files_cnt = 0;
|
let mut processed_files_cnt = 0;
|
||||||
@@ -678,34 +678,34 @@ unsafe fn export_backup(context: &Context, dir: impl AsRef<Path>) -> Result<()>
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
).unwrap();
|
).unwrap();
|
||||||
} else {
|
|
||||||
error!(
|
|
||||||
context,
|
|
||||||
"Backup: Cannot copy from blob-directory \"{}\".",
|
|
||||||
context.get_blobdir().display(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
info!(context, "Backup: No files to copy.",);
|
error!(
|
||||||
}
|
context,
|
||||||
if ok_to_continue {
|
"Backup: Cannot copy from blob-directory \"{}\".",
|
||||||
if sql
|
context.get_blobdir().display(),
|
||||||
.set_config_int(context, "backup_time", now as i32)
|
);
|
||||||
.is_ok()
|
|
||||||
{
|
|
||||||
context.call_cb(Event::ImexFileWritten(dest_path_filename.clone()));
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error!(
|
info!(context, "Backup: No files to copy.",);
|
||||||
context,
|
}
|
||||||
"Backup: Cannot get info for blob-directory \"{}\".",
|
if ok_to_continue {
|
||||||
context.get_blobdir().display(),
|
if sql
|
||||||
);
|
.set_config_int(context, "backup_time", now as i32)
|
||||||
};
|
.is_ok()
|
||||||
}
|
{
|
||||||
|
context.call_cb(Event::ImexFileWritten(dest_path_filename.clone()));
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error!(
|
||||||
|
context,
|
||||||
|
"Backup: Cannot get info for blob-directory \"{}\".",
|
||||||
|
context.get_blobdir().display(),
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if 0 != delete_dest_file {
|
if 0 != delete_dest_file {
|
||||||
dc_delete_file(context, &dest_path_filename);
|
dc_delete_file(context, &dest_path_filename);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user