@@ -67,7 +67,7 @@ impl Executor {
6767 let future = async move {
6868 info ! ( "Searching {song} with engine {engine_id}…" ) ;
6969
70- let result = engine
70+ let mut result = engine
7171 . search ( song, ctx)
7272 . await
7373 . map_err ( ExecutorError :: EngineSearchError ) ?
@@ -76,11 +76,12 @@ impl Executor {
7676 } ) ?;
7777
7878 // Try to retrieve to check if the source available to retrieve.
79- // FIXME: cache it
80- engine
81- . retrieve ( & result. identifier , ctx)
82- . await
83- . map_err ( ExecutorError :: EngineRetrieveError ) ?;
79+ result. pre_retrieve_result = Some (
80+ engine
81+ . retrieve ( & result. identifier , ctx)
82+ . await
83+ . map_err ( ExecutorError :: EngineRetrieveError ) ?,
84+ ) ;
8485
8586 // Specify the Error type explicitly.
8687 Ok :: < SongSearchInformation , ExecutorError > ( result)
@@ -130,11 +131,15 @@ impl Executor {
130131 ) -> ExecutorResult < RetrievedSongInfo > {
131132 info ! ( "Retrieving song from {}…" , song. source) ;
132133
133- let engine = self . resolve_engine ( & song. source ) ?;
134- engine
135- . retrieve ( & song. identifier , ctx)
136- . await
137- . map_err ( ExecutorError :: EngineRetrieveError )
134+ if let Some ( ref retrieved) = song. pre_retrieve_result {
135+ Ok ( retrieved. clone ( ) )
136+ } else {
137+ let engine = self . resolve_engine ( & song. source ) ?;
138+ engine
139+ . retrieve ( & song. identifier , ctx)
140+ . await
141+ . map_err ( ExecutorError :: EngineRetrieveError )
142+ }
138143 }
139144
140145 /// Validate engines to check if the engines specified are all registered.
0 commit comments