Skip to content

Commit 6cb94c4

Browse files
committed
fix: linter errors
1 parent 04c3199 commit 6cb94c4

File tree

4 files changed

+49
-60
lines changed

4 files changed

+49
-60
lines changed

src/models/torrent_file.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,19 @@ impl Torrent {
8080
torrent_nodes: Vec<(String, i64)>,
8181
) -> Self {
8282
let pieces_or_root_hash = if db_torrent.is_bep_30 == 0 {
83-
match &db_torrent.pieces {
84-
Some(pieces) => pieces.clone(),
85-
None => {
86-
error!("Invalid torrent #{}. Null `pieces` in database", db_torrent.torrent_id);
87-
String::new()
88-
}
83+
if let Some(pieces) = &db_torrent.pieces {
84+
pieces.clone()
85+
} else {
86+
error!("Invalid torrent #{}. Null `pieces` in database", db_torrent.torrent_id);
87+
String::new()
8988
}
9089
} else {
9190
// A BEP-30 torrent
92-
match &db_torrent.root_hash {
93-
Some(root_hash) => root_hash.clone(),
94-
None => {
95-
error!("Invalid torrent #{}. Null `root_hash` in database", db_torrent.torrent_id);
96-
String::new()
97-
}
91+
if let Some(root_hash) = &db_torrent.root_hash {
92+
root_hash.clone()
93+
} else {
94+
error!("Invalid torrent #{}. Null `root_hash` in database", db_torrent.torrent_id);
95+
String::new()
9896
}
9997
};
10098

src/services/user.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -134,24 +134,21 @@ impl RegistrationService {
134134
drop(self.user_repository.grant_admin_role(&user_id).await);
135135
}
136136

137-
match &registration.email {
138-
Some(email) => {
139-
if email.verification_required {
140-
// Email verification is enabled
141-
if let Some(email) = opt_email {
142-
let mail_res = self
143-
.mailer
144-
.send_verification_mail(&email, &registration_form.username, user_id, api_base_url)
145-
.await;
146-
147-
if mail_res.is_err() {
148-
drop(self.user_repository.delete(&user_id).await);
149-
return Err(ServiceError::FailedToSendVerificationEmail);
150-
}
137+
if let Some(email) = &registration.email {
138+
if email.verification_required {
139+
// Email verification is enabled
140+
if let Some(email) = opt_email {
141+
let mail_res = self
142+
.mailer
143+
.send_verification_mail(&email, &registration_form.username, user_id, api_base_url)
144+
.await;
145+
146+
if mail_res.is_err() {
147+
drop(self.user_repository.delete(&user_id).await);
148+
return Err(ServiceError::FailedToSendVerificationEmail);
151149
}
152150
}
153151
}
154-
None => (),
155152
}
156153

157154
Ok(user_id)

src/web/api/server/mod.rs

+24-27
Original file line numberDiff line numberDiff line change
@@ -126,33 +126,30 @@ pub enum Error {
126126
}
127127

128128
pub async fn make_rust_tls(tsl_config: &Option<Tsl>) -> Option<Result<RustlsConfig, Error>> {
129-
match tsl_config {
130-
Some(tsl) => {
131-
if let (Some(cert), Some(key)) = (tsl.ssl_cert_path.clone(), tsl.ssl_key_path.clone()) {
132-
info!("Using https. Cert path: {cert}.");
133-
info!("Using https. Key path: {key}.");
134-
135-
let ssl_cert_path = cert.clone().to_string();
136-
let ssl_key_path = key.clone().to_string();
137-
138-
Some(
139-
RustlsConfig::from_pem_file(cert, key)
140-
.await
141-
.map_err(|err| Error::BadTlsConfig {
142-
source: (Arc::new(err) as DynError).into(),
143-
ssl_cert_path,
144-
ssl_key_path,
145-
}),
146-
)
147-
} else {
148-
Some(Err(Error::MissingTlsConfig {
149-
location: Location::caller(),
150-
}))
151-
}
152-
}
153-
None => {
154-
info!("TLS not enabled");
155-
None
129+
if let Some(tsl) = tsl_config {
130+
if let (Some(cert), Some(key)) = (tsl.ssl_cert_path.clone(), tsl.ssl_key_path.clone()) {
131+
info!("Using https. Cert path: {cert}.");
132+
info!("Using https. Key path: {key}.");
133+
134+
let ssl_cert_path = cert.clone().to_string();
135+
let ssl_key_path = key.clone().to_string();
136+
137+
Some(
138+
RustlsConfig::from_pem_file(cert, key)
139+
.await
140+
.map_err(|err| Error::BadTlsConfig {
141+
source: (Arc::new(err) as DynError).into(),
142+
ssl_cert_path,
143+
ssl_key_path,
144+
}),
145+
)
146+
} else {
147+
Some(Err(Error::MissingTlsConfig {
148+
location: Location::caller(),
149+
}))
156150
}
151+
} else {
152+
info!("TLS not enabled");
153+
None
157154
}
158155
}

tests/environments/app_starter.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,9 @@ impl AppStarter {
6868
}
6969

7070
pub fn stop(&mut self) {
71-
match &self.running_state {
72-
Some(running_state) => {
73-
running_state.app_handle.abort();
74-
self.running_state = None;
75-
}
76-
None => {}
71+
if let Some(running_state) = &self.running_state {
72+
running_state.app_handle.abort();
73+
self.running_state = None;
7774
}
7875
}
7976

0 commit comments

Comments
 (0)