@@ -246,80 +246,70 @@ impl SourceExecutor for Executor {
246246 . boxed ( )
247247 }
248248
249- async fn get_value ( & self , key : & KeyValue ) -> Result < Option < SourceData < ' async_trait > > > {
249+ async fn get_value ( & self , key : & KeyValue ) -> Result < Option < FieldValues > > {
250250 let file_id = key. str_value ( ) ?;
251-
252251 let resp = self
253252 . drive_hub
254253 . files ( )
255254 . get ( file_id)
256255 . add_scope ( Scope :: Readonly )
257- . param ( "fields" , "id,name,mimeType,trashed,modifiedTime " )
256+ . param ( "fields" , "id,name,mimeType,trashed" )
258257 . doit ( )
259258 . await
260259 . or_not_found ( ) ?;
261260 let file = match resp {
262261 Some ( ( _, file) ) if file. trashed != Some ( true ) => file,
263262 _ => return Ok ( None ) ,
264263 } ;
265-
266- let modified_time = file. modified_time ;
267- let value = async move {
268- let type_n_body = if let Some ( export_mime_type) = file
269- . mime_type
270- . as_ref ( )
271- . and_then ( |mime_type| EXPORT_MIME_TYPES . get ( mime_type. as_str ( ) ) )
272- {
273- let target_mime_type = if self . binary {
274- export_mime_type. binary
275- } else {
276- export_mime_type. text
277- } ;
278- self . drive_hub
279- . files ( )
280- . export ( file_id, target_mime_type)
281- . add_scope ( Scope :: Readonly )
282- . doit ( )
283- . await
284- . or_not_found ( ) ?
285- . map ( |content| ( Some ( target_mime_type. to_string ( ) ) , content. into_body ( ) ) )
264+ let type_n_body = if let Some ( export_mime_type) = file
265+ . mime_type
266+ . as_ref ( )
267+ . and_then ( |mime_type| EXPORT_MIME_TYPES . get ( mime_type. as_str ( ) ) )
268+ {
269+ let target_mime_type = if self . binary {
270+ export_mime_type. binary
286271 } else {
287- self . drive_hub
288- . files ( )
289- . get ( file_id)
290- . add_scope ( Scope :: Readonly )
291- . param ( "alt" , "media" )
292- . doit ( )
293- . await
294- . or_not_found ( ) ?
295- . map ( |( resp, _) | ( file. mime_type , resp. into_body ( ) ) )
272+ export_mime_type. text
296273 } ;
297- let value = match type_n_body {
298- Some ( ( mime_type, resp_body) ) => {
299- let content = resp_body. collect ( ) . await ?;
274+ self . drive_hub
275+ . files ( )
276+ . export ( file_id, target_mime_type)
277+ . add_scope ( Scope :: Readonly )
278+ . doit ( )
279+ . await
280+ . or_not_found ( ) ?
281+ . map ( |content| ( Some ( target_mime_type. to_string ( ) ) , content. into_body ( ) ) )
282+ } else {
283+ self . drive_hub
284+ . files ( )
285+ . get ( file_id)
286+ . add_scope ( Scope :: Readonly )
287+ . param ( "alt" , "media" )
288+ . doit ( )
289+ . await
290+ . or_not_found ( ) ?
291+ . map ( |( resp, _) | ( file. mime_type , resp. into_body ( ) ) )
292+ } ;
293+ let value = match type_n_body {
294+ Some ( ( mime_type, resp_body) ) => {
295+ let content = resp_body. collect ( ) . await ?;
300296
301- let fields = vec ! [
302- file. name. unwrap_or_default( ) . into( ) ,
303- mime_type. into( ) ,
304- if self . binary {
305- content. to_bytes( ) . to_vec( ) . into( )
306- } else {
307- String :: from_utf8_lossy( & content. to_bytes( ) )
308- . to_string( )
309- . into( )
310- } ,
311- ] ;
312- Some ( FieldValues { fields } )
313- }
314- None => None ,
315- } ;
316- Ok ( value)
317- }
318- . boxed ( ) ;
319- Ok ( Some ( SourceData {
320- ordinal : modified_time. map ( |t| t. try_into ( ) ) . transpose ( ) ?,
321- value,
322- } ) )
297+ let fields = vec ! [
298+ file. name. unwrap_or_default( ) . into( ) ,
299+ mime_type. into( ) ,
300+ if self . binary {
301+ content. to_bytes( ) . to_vec( ) . into( )
302+ } else {
303+ String :: from_utf8_lossy( & content. to_bytes( ) )
304+ . to_string( )
305+ . into( )
306+ } ,
307+ ] ;
308+ Some ( FieldValues { fields } )
309+ }
310+ None => None ,
311+ } ;
312+ Ok ( value)
323313 }
324314}
325315
0 commit comments