File tree 8 files changed +15
-20
lines changed
8 files changed +15
-20
lines changed Original file line number Diff line number Diff line change @@ -60,15 +60,13 @@ fn main() {
60
60
// Attempt to create and write to the file
61
61
let mut file = match File :: create ( & file_path) {
62
62
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 ( ) ) ,
64
64
} ;
65
65
66
66
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 ( ) ) ;
68
68
}
69
-
70
- println ! ( "File successfully written to {file_path:?}" ) ;
71
69
}
72
70
Err ( e) => panic ! ( "Error encoding torrent: {e}" ) ,
73
- } ;
71
+ }
74
72
}
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ pub async fn run() -> anyhow::Result<()> {
196
196
info ! ( target: "seeder" , "Uploaded torrent: {}" , json. yellow( ) ) ;
197
197
}
198
198
Err ( err) => print ! ( "Error uploading torrent {err:?}" ) ,
199
- } ;
199
+ }
200
200
201
201
if i != args. number_of_torrents {
202
202
sleep ( Duration :: from_secs ( args. interval ) ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ lazy_static! {
25
25
println!( "Parsing error(s): {e}" ) ;
26
26
:: std:: process:: exit( 1 ) ;
27
27
}
28
- } ;
28
+ }
29
29
30
30
tera. autoescape_on( vec![ ".html" , ".sql" ] ) ;
31
31
tera. register_filter( "do_nothing" , do_nothing_filter) ;
Original file line number Diff line number Diff line change 1
1
//! Torrent service.
2
+ use std:: fmt:: Write as _;
2
3
use std:: sync:: Arc ;
3
4
4
5
use bittorrent_primitives:: info_hash:: InfoHash ;
@@ -550,7 +551,7 @@ impl Index {
550
551
551
552
// Add trackers from torrent file to magnet link
552
553
for tracker in & torrent_response. trackers {
553
- magnet . push_str ( & format ! ( "&tr={}" , urlencoding:: encode( tracker) ) ) ;
554
+ let _ = write ! ( & mut magnet , "&tr={}" , urlencoding:: encode( tracker) ) ;
554
555
}
555
556
556
557
torrent_response. magnet_link = magnet;
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ impl RegistrationService {
206
206
207
207
if self . user_profile_repository . verify_email ( & user_id) . await . is_err ( ) {
208
208
return Err ( ServiceError :: DatabaseError ) ;
209
- } ;
209
+ }
210
210
211
211
Ok ( true )
212
212
}
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ async fn start_server(
107
107
. serve ( router. into_make_service_with_connect_info :: < std:: net:: SocketAddr > ( ) )
108
108
. await
109
109
. expect ( "API server should be running" ) ,
110
- } ;
110
+ }
111
111
}
112
112
113
113
#[ 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
336
336
let data = field. bytes ( ) . await . unwrap ( ) ;
337
337
if data. is_empty ( ) {
338
338
continue ;
339
- } ;
339
+ }
340
340
title = String :: from_utf8 ( data. to_vec ( ) ) . map_err ( |_| errors:: Request :: TitleIsNotValidUtf8 ) ?;
341
341
}
342
342
"description" => {
343
343
let data = field. bytes ( ) . await . unwrap ( ) ;
344
344
if data. is_empty ( ) {
345
345
continue ;
346
- } ;
346
+ }
347
347
description = String :: from_utf8 ( data. to_vec ( ) ) . map_err ( |_| errors:: Request :: DescriptionIsNotValidUtf8 ) ?;
348
348
}
349
349
"category" => {
350
350
let data = field. bytes ( ) . await . unwrap ( ) ;
351
351
if data. is_empty ( ) {
352
352
continue ;
353
- } ;
353
+ }
354
354
category = String :: from_utf8 ( data. to_vec ( ) ) . map_err ( |_| errors:: Request :: CategoryIsNotValidUtf8 ) ?;
355
355
}
356
356
"tags" => {
357
357
let data = field. bytes ( ) . await . unwrap ( ) ;
358
358
if data. is_empty ( ) {
359
359
continue ;
360
- } ;
360
+ }
361
361
let string_data = String :: from_utf8 ( data. to_vec ( ) ) . map_err ( |_| errors:: Request :: TagsArrayIsNotValidUtf8 ) ?;
362
362
tags = serde_json:: from_str ( & string_data) . map_err ( |_| errors:: Request :: TagsArrayIsNotValidJson ) ?;
363
363
}
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ impl TestEnv {
84
84
pub fn provides_a_private_tracker ( & self ) -> bool {
85
85
if !self . is_shared ( ) {
86
86
return false ;
87
- } ;
87
+ }
88
88
89
89
match self . server_settings ( ) {
90
90
Some ( settings) => settings. tracker . private ,
@@ -148,11 +148,7 @@ impl TestEnv {
148
148
State :: RunningShared => {
149
149
let connect_url_env_var = ENV_VAR_DB_CONNECT_URL ;
150
150
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 ( )
156
152
}
157
153
State :: RunningIsolated => internal_connect_url,
158
154
State :: Stopped => None ,
You can’t perform that action at this time.
0 commit comments