mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-27 16:48:58 +00:00
feat(ecstore): LocalDisk writes file by spawn_blocking
This commit is contained in:
@@ -671,12 +671,21 @@ impl LocalDisk {
|
||||
}
|
||||
};
|
||||
|
||||
let data: &[u8] = match &data {
|
||||
InternalBuf::Ref(buf) => buf,
|
||||
InternalBuf::Owned(buf) => buf.as_ref(),
|
||||
};
|
||||
|
||||
f.write_all(data).await.map_err(to_file_error)?;
|
||||
match data {
|
||||
InternalBuf::Ref(buf) => {
|
||||
f.write_all(buf).await.map_err(to_file_error)?;
|
||||
}
|
||||
InternalBuf::Owned(buf) => {
|
||||
// Reduce one copy by using the owned buffer directly.
|
||||
// It may be more efficient for larger writes.
|
||||
let mut f = f.into_std().await;
|
||||
let task = tokio::task::spawn_blocking(move || {
|
||||
use std::io::Write as _;
|
||||
f.write_all(buf.as_ref()).map_err(to_file_error)
|
||||
});
|
||||
task.await??;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user