fix clippy lints

This commit is contained in:
funtimes909
2026-04-05 12:57:18 +12:00
parent de74ed9f7d
commit e72e51f60c
5 changed files with 31 additions and 32 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ pub async fn run(pool: &PgPool) {
error!("Error while downloading countries database from ipinfo: {e}");
};
if let Err(e) = insert_records_to_database(&pool).await {
if let Err(e) = insert_records_to_database(pool).await {
error!("Error while inserting rows to countries table: {e}");
}
}
+2 -2
View File
@@ -4,10 +4,10 @@ use std::str::FromStr;
use super::protocol::response::MinecraftServer;
use chrono::NaiveDateTime;
use sqlx::postgres::{PgArguments, PgQueryResult};
use sqlx::postgres::PgQueryResult;
use sqlx::types::Uuid;
use sqlx::types::ipnet::IpNet;
use sqlx::{Encode, Execute, Pool, Postgres, QueryBuilder, Row};
use sqlx::{Pool, Postgres, QueryBuilder, Row};
#[derive(Debug, Clone)]
pub struct Database {
+7 -7
View File
@@ -117,17 +117,17 @@ impl MinecraftServer {
}
// Check for duplicate uuids
self.players.sample.as_ref().map(|a| {
if let Some(a) = &self.players.sample {
a.iter().for_each(|a| {
let uuid = Uuid::parse_str(&a.id).unwrap();
if let Ok(uuid) = Uuid::parse_str(&a.id) {
if seen_uuids.contains(&uuid) {
is_fake_sample = true
}
if seen_uuids.contains(&uuid) {
is_fake_sample = true
seen_uuids.insert(uuid);
}
seen_uuids.insert(uuid);
})
});
}
is_fake_sample
}
+19 -19
View File
@@ -65,27 +65,27 @@ impl DiscoveryScanner {
let socket = SocketAddrV4::new(address, port);
let mut stream = tokio::net::TcpStream::connect(socket).await.unwrap();
if let Ok(response) = simple_ping(&mut stream).await {
if let Ok(server) = serde_json::from_str::<MinecraftServer>(&response) {
let address = IpNet::from(Ipv4Net::from(address));
if let Ok(response) = simple_ping(&mut stream).await
&& let Ok(server) = serde_json::from_str::<MinecraftServer>(&response)
{
let address = IpNet::from(Ipv4Net::from(address));
if server.has_opted_out() {
println!("Deleting server!");
database_clone.delete_server(address).await.unwrap();
}
let update_operation = ServerUpdateOperation {
server,
address,
port: port as i32,
timestamp: chrono::Utc::now().naive_utc().with_nanosecond(0).unwrap(),
database: database_clone,
};
update_operation.update_or_insert_server().await.unwrap();
update_operation.update_or_insert_players().await.unwrap();
update_operation.update_or_insert_mods().await.unwrap();
if server.has_opted_out() {
println!("Deleting server!");
database_clone.delete_server(address).await.unwrap();
}
let update_operation = ServerUpdateOperation {
server,
address,
port: port as i32,
timestamp: chrono::Utc::now().naive_utc().with_nanosecond(0).unwrap(),
database: database_clone,
};
update_operation.update_or_insert_server().await.unwrap();
update_operation.update_or_insert_players().await.unwrap();
update_operation.update_or_insert_mods().await.unwrap();
}
});
}
+2 -3
View File
@@ -48,8 +48,8 @@ impl Rescanner {
let database_clone = self.database.clone();
if let Ok(ping_response) = simple_ping(&mut stream).await {
if let Ok(server) = serde_json::from_str::<MinecraftServer>(&ping_response) {
if let Ok(ping_response) = simple_ping(&mut stream).await
&& let Ok(server) = serde_json::from_str::<MinecraftServer>(&ping_response) {
if server.has_opted_out() {
database_clone.delete_server(address).await.unwrap();
@@ -67,7 +67,6 @@ impl Rescanner {
update_operation.update_or_insert_players().await.unwrap();
update_operation.update_or_insert_mods().await.unwrap();
}
}
bar.inc(1);
}