File tree Expand file tree Collapse file tree
runtime/src/storage/tokio Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,13 +102,28 @@ impl crate::Blob for Blob {
102102 offset : u64 ,
103103 bufs : impl Into < IoBufs > + Send ,
104104 ) -> Result < ( ) , Error > {
105- let bufs = bufs. into ( ) ;
105+ let mut bufs = bufs. into ( ) ;
106106 if !bufs. has_remaining ( ) {
107107 return Ok ( ( ) ) ;
108108 }
109109
110- self . write_at ( offset, bufs) . await ?;
111- self . sync ( ) . await
110+ let mut file = self . file . lock ( ) . await ;
111+ let offset = offset
112+ . checked_add ( Header :: SIZE_U64 )
113+ . ok_or ( Error :: OffsetOverflow ) ?;
114+ file. seek ( SeekFrom :: Start ( offset) )
115+ . await
116+ . map_err ( |_| Error :: WriteFailed ) ?;
117+
118+ if let Some ( buf) = bufs. as_single ( ) {
119+ Self :: write_single_at ( & mut file, buf. as_ref ( ) ) . await ?;
120+ } else {
121+ Self :: write_vectored_at ( & mut file, & mut bufs) . await ?;
122+ }
123+
124+ file. sync_all ( )
125+ . await
126+ . map_err ( |e| Error :: BlobSyncFailed ( self . partition . clone ( ) , hex ( & self . name ) , e) )
112127 }
113128
114129 async fn resize ( & self , len : u64 ) -> Result < ( ) , Error > {
You can’t perform that action at this time.
0 commit comments