@@ -223,7 +223,7 @@ async fn main() -> Result<()> {
223223 config. initial_peer . clone ( )
224224 }
225225 } ,
226- list_only : false ,
226+ list_only : preload . regex . is_none ( ) ,
227227 // the destination folder to preload files match `preload_regex`
228228 // * e.g. images for audio albums
229229 output_folder : preload. tmp_dir ( & h, true ) ?. to_str ( ) . map ( |s| s. to_string ( ) ) ,
@@ -234,7 +234,14 @@ async fn main() -> Result<()> {
234234 . await
235235 {
236236 Ok ( r) => match r {
237+ Ok ( AddTorrentResponse :: ListOnly ( l) ) => {
238+ assert ! ( preload. regex. is_none( ) ) ;
239+ debug ! ( "persist bytes for torrent file `{h}`..." ) ;
240+ preload. commit ( & h, l. torrent_bytes . to_vec ( ) , None ) ?;
241+ info ! ( "torrent `{h}` resolved." )
242+ }
237243 Ok ( AddTorrentResponse :: Added ( _, mt) ) => {
244+ assert ! ( preload. regex. is_some( ) ) ;
238245 assert ! ( mt. is_paused( ) ) ;
239246 let mut keep_files = HashSet :: with_capacity (
240247 config. preload_max_filecount . unwrap_or_default ( ) ,
@@ -264,10 +271,10 @@ async fn main() -> Result<()> {
264271 ) ;
265272 continue ;
266273 }
267- if preload. regex . as_ref ( ) . is_none_or ( |r| {
274+ if preload. regex . as_ref ( ) . is_some_and ( |r| {
268275 !r. is_match ( & info. relative_filename . to_string_lossy ( ) )
269276 } ) {
270- debug ! ( "regex filter, skip file `{id}` for `{h}` at `{}`" ,
277+ debug ! ( "regex filter match: skip `{id}` for `{h}` at `{}`" ,
271278 info. relative_filename. to_string_lossy( ) ) ;
272279 continue ;
273280 }
@@ -302,7 +309,7 @@ async fn main() -> Result<()> {
302309 preload. commit ( & h, bytes, Some ( keep_files) ) ?;
303310 info ! ( "torrent `{h}` resolved." )
304311 }
305- Ok ( _) => panic ! ( ) ,
312+ Ok ( _) => unreachable ! ( ) ,
306313 Err ( e) => {
307314 warn ! ( "failed to resolve torrent `{h}`: `{e}`, ban for the next queue." ) ;
308315 assert ! ( ban. insert( i) )
0 commit comments