@@ -128,20 +128,31 @@ impl Writeable {
128128 }
129129 }
130130
131- pub fn sync_on_close ( & mut self , sync_on_close : SyncOnCloseType ) -> std :: io:: Result < ( ) > {
131+ pub fn sync_all ( & self ) -> io:: Result < ( ) > {
132132 match self {
133- Writeable :: Dyn ( d) => {
134- crate :: utils:: sync_on_close:: sync_on_close_dyn ( sync_on_close, d. as_mut ( ) )
135- } ,
136- Writeable :: Local ( file) => {
137- crate :: utils:: sync_on_close:: sync_on_close ( sync_on_close, file)
138- } ,
133+ Self :: Dyn ( v) => v. sync_all ( ) ,
134+ Self :: Local ( v) => v. sync_all ( ) ,
139135 #[ cfg( feature = "cloud" ) ]
140- Writeable :: Cloud ( _ ) => Ok ( ( ) ) ,
136+ Self :: Cloud ( v ) => v . sync_all ( ) ,
141137 }
142138 }
143139
144- pub fn close ( self ) -> std:: io:: Result < ( ) > {
140+ pub fn sync_data ( & self ) -> io:: Result < ( ) > {
141+ match self {
142+ Self :: Dyn ( v) => v. sync_data ( ) ,
143+ Self :: Local ( v) => v. sync_data ( ) ,
144+ #[ cfg( feature = "cloud" ) ]
145+ Self :: Cloud ( v) => v. sync_data ( ) ,
146+ }
147+ }
148+
149+ pub fn close ( self , sync : SyncOnCloseType ) -> std:: io:: Result < ( ) > {
150+ match sync {
151+ SyncOnCloseType :: All => self . sync_all ( ) ?,
152+ SyncOnCloseType :: Data => self . sync_data ( ) ?,
153+ SyncOnCloseType :: None => { } ,
154+ }
155+
145156 match self {
146157 Self :: Dyn ( mut v) => v. close ( ) ,
147158 Self :: Local ( v) => close_file ( v) ,
@@ -236,22 +247,29 @@ mod async_writeable {
236247 Writeable :: try_new ( path, cloud_options) . and_then ( |x| x. try_into_async_writeable ( ) )
237248 }
238249
239- pub async fn sync_on_close (
240- & mut self ,
241- sync_on_close : SyncOnCloseType ,
242- ) -> std:: io:: Result < ( ) > {
250+ pub async fn sync_all ( & mut self ) -> io:: Result < ( ) > {
243251 match self {
244- Self :: Dyn ( d) => task:: block_in_place ( || {
245- crate :: utils:: sync_on_close:: sync_on_close_dyn ( sync_on_close, d. 0 . as_mut ( ) )
246- } ) ,
247- Self :: Local ( file) => {
248- crate :: utils:: sync_on_close:: tokio_sync_on_close ( sync_on_close, file) . await
249- } ,
252+ Self :: Dyn ( v) => task:: block_in_place ( || v. 0 . as_ref ( ) . sync_all ( ) ) ,
253+ Self :: Local ( v) => v. sync_all ( ) . await ,
254+ Self :: Cloud ( _) => Ok ( ( ) ) ,
255+ }
256+ }
257+
258+ pub async fn sync_data ( & mut self ) -> io:: Result < ( ) > {
259+ match self {
260+ Self :: Dyn ( v) => task:: block_in_place ( || v. 0 . as_ref ( ) . sync_data ( ) ) ,
261+ Self :: Local ( v) => v. sync_data ( ) . await ,
250262 Self :: Cloud ( _) => Ok ( ( ) ) ,
251263 }
252264 }
253265
254- pub async fn close ( self ) -> PolarsResult < ( ) > {
266+ pub async fn close ( mut self , sync : SyncOnCloseType ) -> PolarsResult < ( ) > {
267+ match sync {
268+ SyncOnCloseType :: All => self . sync_all ( ) . await ?,
269+ SyncOnCloseType :: Data => self . sync_data ( ) . await ?,
270+ SyncOnCloseType :: None => { } ,
271+ }
272+
255273 match self {
256274 Self :: Dyn ( mut v) => {
257275 v. shutdown ( ) . await . map_err ( PolarsError :: from) ?;
0 commit comments