mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-29 16:37:07 +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 {
|
match data {
|
||||||
InternalBuf::Ref(buf) => buf,
|
InternalBuf::Ref(buf) => {
|
||||||
InternalBuf::Owned(buf) => buf.as_ref(),
|
f.write_all(buf).await.map_err(to_file_error)?;
|
||||||
};
|
}
|
||||||
|
InternalBuf::Owned(buf) => {
|
||||||
f.write_all(data).await.map_err(to_file_error)?;
|
// 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user