Use fs::rename which is much faster than move_items (#8579) (#8594)

automerge
This commit is contained in:
mergify[bot]
2020-03-03 10:54:36 -08:00
committed by GitHub
parent 4398628265
commit d0de1c913a

View File

@ -528,23 +528,26 @@ impl AccountsDB {
AppendVec::new_relative_path(slot_id, storage_entry.id); AppendVec::new_relative_path(slot_id, storage_entry.id);
let append_vec_abs_path = let append_vec_abs_path =
append_vecs_path.as_ref().join(&append_vec_relative_path); append_vecs_path.as_ref().join(&append_vec_relative_path);
let mut copy_options = CopyOptions::new(); let target = local_dir.join(append_vec_abs_path.file_name().unwrap());
copy_options.overwrite = true; if std::fs::rename(append_vec_abs_path.clone(), target).is_err() {
let e = fs_extra::move_items( let mut copy_options = CopyOptions::new();
&vec![&append_vec_abs_path], copy_options.overwrite = true;
&local_dir, let e = fs_extra::move_items(
&copy_options, &vec![&append_vec_abs_path],
) &local_dir,
.map_err(|e| { &copy_options,
AccountsDB::get_io_error(&format!( )
"Unable to move {:?} to {:?}: {}", .map_err(|e| {
append_vec_abs_path, local_dir, e AccountsDB::get_io_error(&format!(
)) "Unable to move {:?} to {:?}: {}",
}); append_vec_abs_path, local_dir, e
if e.is_err() { ))
info!("{:?}", e); });
continue; if e.is_err() {
} info!("{:?}", e);
continue;
}
};
// Notify the AppendVec of the new file location // Notify the AppendVec of the new file location
let local_path = local_dir.join(append_vec_relative_path); let local_path = local_dir.join(append_vec_relative_path);