@@ -68,7 +68,7 @@ impl InfoHashParam {
68
68
#[ allow( clippy:: unused_async) ]
69
69
pub async fn download_torrent_handler (
70
70
State ( app_data) : State < Arc < AppData > > ,
71
- ExtractOptionalLoggedInUser ( opt_user_id ) : ExtractOptionalLoggedInUser ,
71
+ ExtractOptionalLoggedInUser ( maybe_user_id ) : ExtractOptionalLoggedInUser ,
72
72
Path ( info_hash) : Path < InfoHashParam > ,
73
73
) -> Response {
74
74
let Ok ( info_hash) = InfoHash :: from_str ( & info_hash. lowercase ( ) ) else {
@@ -78,12 +78,12 @@ pub async fn download_torrent_handler(
78
78
debug ! ( "Downloading torrent: {:?}" , info_hash. to_hex_string( ) ) ;
79
79
80
80
if let Some ( redirect_response) =
81
- redirect_to_download_url_using_canonical_info_hash_if_needed ( & app_data, & info_hash, opt_user_id ) . await
81
+ redirect_to_download_url_using_canonical_info_hash_if_needed ( & app_data, & info_hash, maybe_user_id ) . await
82
82
{
83
83
debug ! ( "Redirecting to URL with canonical info-hash" ) ;
84
84
redirect_response
85
85
} else {
86
- let torrent = match app_data. torrent_service . get_torrent ( & info_hash, opt_user_id ) . await {
86
+ let torrent = match app_data. torrent_service . get_torrent ( & info_hash, maybe_user_id ) . await {
87
87
Ok ( torrent) => torrent,
88
88
Err ( error) => return error. into_response ( ) ,
89
89
} ;
@@ -103,9 +103,13 @@ pub async fn download_torrent_handler(
103
103
async fn redirect_to_download_url_using_canonical_info_hash_if_needed (
104
104
app_data : & Arc < AppData > ,
105
105
info_hash : & InfoHash ,
106
- opt_user_id : Option < i64 > ,
106
+ maybe_user_id : Option < i64 > ,
107
107
) -> Option < Response > {
108
- match app_data. torrent_service . get_canonical_info_hash ( info_hash, opt_user_id) . await {
108
+ match app_data
109
+ . torrent_service
110
+ . get_canonical_info_hash ( info_hash, maybe_user_id)
111
+ . await
112
+ {
109
113
Ok ( Some ( canonical_info_hash) ) => {
110
114
if canonical_info_hash != * info_hash {
111
115
return Some (
@@ -134,11 +138,11 @@ async fn redirect_to_download_url_using_canonical_info_hash_if_needed(
134
138
pub async fn get_torrents_handler (
135
139
State ( app_data) : State < Arc < AppData > > ,
136
140
Query ( criteria) : Query < ListingRequest > ,
137
- ExtractOptionalLoggedInUser ( opt_user_id ) : ExtractOptionalLoggedInUser ,
141
+ ExtractOptionalLoggedInUser ( maybe_user_id ) : ExtractOptionalLoggedInUser ,
138
142
) -> Response {
139
143
match app_data
140
144
. torrent_service
141
- . generate_torrent_info_listing ( & criteria, opt_user_id )
145
+ . generate_torrent_info_listing ( & criteria, maybe_user_id )
142
146
. await
143
147
{
144
148
Ok ( torrents_response) => Json ( OkResponseData { data : torrents_response } ) . into_response ( ) ,
@@ -157,19 +161,19 @@ pub async fn get_torrents_handler(
157
161
#[ allow( clippy:: unused_async) ]
158
162
pub async fn get_torrent_info_handler (
159
163
State ( app_data) : State < Arc < AppData > > ,
160
- ExtractOptionalLoggedInUser ( opt_user_id ) : ExtractOptionalLoggedInUser ,
164
+ ExtractOptionalLoggedInUser ( maybe_user_id ) : ExtractOptionalLoggedInUser ,
161
165
Path ( info_hash) : Path < InfoHashParam > ,
162
166
) -> Response {
163
167
let Ok ( info_hash) = InfoHash :: from_str ( & info_hash. lowercase ( ) ) else {
164
168
return errors:: Request :: InvalidInfoHashParam . into_response ( ) ;
165
169
} ;
166
170
167
171
if let Some ( redirect_response) =
168
- redirect_to_details_url_using_canonical_info_hash_if_needed ( & app_data, & info_hash, opt_user_id ) . await
172
+ redirect_to_details_url_using_canonical_info_hash_if_needed ( & app_data, & info_hash, maybe_user_id ) . await
169
173
{
170
174
redirect_response
171
175
} else {
172
- match app_data. torrent_service . get_torrent_info ( & info_hash, opt_user_id ) . await {
176
+ match app_data. torrent_service . get_torrent_info ( & info_hash, maybe_user_id ) . await {
173
177
Ok ( torrent_response) => Json ( OkResponseData { data : torrent_response } ) . into_response ( ) ,
174
178
Err ( error) => error. into_response ( ) ,
175
179
}
@@ -179,9 +183,13 @@ pub async fn get_torrent_info_handler(
179
183
async fn redirect_to_details_url_using_canonical_info_hash_if_needed (
180
184
app_data : & Arc < AppData > ,
181
185
info_hash : & InfoHash ,
182
- opt_user_id : Option < i64 > ,
186
+ maybe_user_id : Option < i64 > ,
183
187
) -> Option < Response > {
184
- match app_data. torrent_service . get_canonical_info_hash ( info_hash, opt_user_id) . await {
188
+ match app_data
189
+ . torrent_service
190
+ . get_canonical_info_hash ( info_hash, maybe_user_id)
191
+ . await
192
+ {
185
193
Ok ( Some ( canonical_info_hash) ) => {
186
194
if canonical_info_hash != * info_hash {
187
195
return Some (
0 commit comments