File tree Expand file tree Collapse file tree 8 files changed +15
-20
lines changed Expand file tree Collapse file tree 8 files changed +15
-20
lines changed Original file line number Diff line number Diff line change @@ -60,15 +60,13 @@ fn main() {
6060 // Attempt to create and write to the file
6161 let mut file = match File :: create ( & file_path) {
6262 Ok ( file) => file,
63- Err ( e) => panic ! ( "Failed to create file {file_path:? }: {e}" ) ,
63+ Err ( e) => panic ! ( "Failed to create file {}: {e}" , file_path . display ( ) ) ,
6464 } ;
6565
6666 if let Err ( e) = file. write_all ( & bytes) {
67- panic ! ( "Failed to write to file {file_path:? }: {e}" ) ;
67+ panic ! ( "Failed to write to file {}: {e}" , file_path . display ( ) ) ;
6868 }
69-
70- println ! ( "File successfully written to {file_path:?}" ) ;
7169 }
7270 Err ( e) => panic ! ( "Error encoding torrent: {e}" ) ,
73- } ;
71+ }
7472}
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ pub async fn run() -> anyhow::Result<()> {
196196 info ! ( target: "seeder" , "Uploaded torrent: {}" , json. yellow( ) ) ;
197197 }
198198 Err ( err) => print ! ( "Error uploading torrent {err:?}" ) ,
199- } ;
199+ }
200200
201201 if i != args. number_of_torrents {
202202 sleep ( Duration :: from_secs ( args. interval ) ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ lazy_static! {
2525 println!( "Parsing error(s): {e}" ) ;
2626 :: std:: process:: exit( 1 ) ;
2727 }
28- } ;
28+ }
2929
3030 tera. autoescape_on( vec![ ".html" , ".sql" ] ) ;
3131 tera. register_filter( "do_nothing" , do_nothing_filter) ;
Original file line number Diff line number Diff line change 11//! Torrent service.
2+ use std:: fmt:: Write as _;
23use std:: sync:: Arc ;
34
45use bittorrent_primitives:: info_hash:: InfoHash ;
@@ -550,7 +551,7 @@ impl Index {
550551
551552 // Add trackers from torrent file to magnet link
552553 for tracker in & torrent_response. trackers {
553- magnet . push_str ( & format ! ( "&tr={}" , urlencoding:: encode( tracker) ) ) ;
554+ let _ = write ! ( & mut magnet , "&tr={}" , urlencoding:: encode( tracker) ) ;
554555 }
555556
556557 torrent_response. magnet_link = magnet;
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ impl RegistrationService {
206206
207207 if self . user_profile_repository . verify_email ( & user_id) . await . is_err ( ) {
208208 return Err ( ServiceError :: DatabaseError ) ;
209- } ;
209+ }
210210
211211 Ok ( true )
212212 }
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ async fn start_server(
107107 . serve ( router. into_make_service_with_connect_info :: < std:: net:: SocketAddr > ( ) )
108108 . await
109109 . expect ( "API server should be running" ) ,
110- } ;
110+ }
111111}
112112
113113#[ derive( Error , Debug ) ]
Original file line number Diff line number Diff line change @@ -336,28 +336,28 @@ async fn build_add_torrent_request_from_payload(mut payload: Multipart) -> Resul
336336 let data = field. bytes ( ) . await . unwrap ( ) ;
337337 if data. is_empty ( ) {
338338 continue ;
339- } ;
339+ }
340340 title = String :: from_utf8 ( data. to_vec ( ) ) . map_err ( |_| errors:: Request :: TitleIsNotValidUtf8 ) ?;
341341 }
342342 "description" => {
343343 let data = field. bytes ( ) . await . unwrap ( ) ;
344344 if data. is_empty ( ) {
345345 continue ;
346- } ;
346+ }
347347 description = String :: from_utf8 ( data. to_vec ( ) ) . map_err ( |_| errors:: Request :: DescriptionIsNotValidUtf8 ) ?;
348348 }
349349 "category" => {
350350 let data = field. bytes ( ) . await . unwrap ( ) ;
351351 if data. is_empty ( ) {
352352 continue ;
353- } ;
353+ }
354354 category = String :: from_utf8 ( data. to_vec ( ) ) . map_err ( |_| errors:: Request :: CategoryIsNotValidUtf8 ) ?;
355355 }
356356 "tags" => {
357357 let data = field. bytes ( ) . await . unwrap ( ) ;
358358 if data. is_empty ( ) {
359359 continue ;
360- } ;
360+ }
361361 let string_data = String :: from_utf8 ( data. to_vec ( ) ) . map_err ( |_| errors:: Request :: TagsArrayIsNotValidUtf8 ) ?;
362362 tags = serde_json:: from_str ( & string_data) . map_err ( |_| errors:: Request :: TagsArrayIsNotValidJson ) ?;
363363 }
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ impl TestEnv {
8484 pub fn provides_a_private_tracker ( & self ) -> bool {
8585 if !self . is_shared ( ) {
8686 return false ;
87- } ;
87+ }
8888
8989 match self . server_settings ( ) {
9090 Some ( settings) => settings. tracker . private ,
@@ -148,11 +148,7 @@ impl TestEnv {
148148 State :: RunningShared => {
149149 let connect_url_env_var = ENV_VAR_DB_CONNECT_URL ;
150150
151- if let Ok ( connect_url) = env:: var ( connect_url_env_var) {
152- Some ( connect_url)
153- } else {
154- None
155- }
151+ env:: var ( connect_url_env_var) . ok ( )
156152 }
157153 State :: RunningIsolated => internal_connect_url,
158154 State :: Stopped => None ,
You can’t perform that action at this time.
0 commit comments