Clippy CI/CD (#67)

* feat: add clippy ci

* fix: clippy errors

* fix: ci/cd

* fix: update ci packages

* fix: add gtk3 to ci deps

* fix: add webkit to ci deps

* fix: ci deps and perms

* fix: add clippy settings to lib.rs
This commit is contained in:
DecDuck
2025-07-18 17:36:04 +10:00
committed by GitHub
parent 495d93705e
commit f9fdf151ea
36 changed files with 157 additions and 265 deletions

View File

@ -5,7 +5,7 @@ use std::{
use crate::{
database::{db::borrow_db_checked, models::data::GameDownloadStatus},
download_manager::{download_manager::DownloadManagerSignal, downloadable::Downloadable},
download_manager::{download_manager_frontend::DownloadManagerSignal, downloadable::Downloadable},
error::download_manager_error::DownloadManagerError,
AppState,
};

View File

@ -3,7 +3,7 @@ use crate::database::db::{borrow_db_checked, borrow_db_mut_checked};
use crate::database::models::data::{
ApplicationTransientStatus, DownloadType, DownloadableMetadata,
};
use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus};
use crate::download_manager::download_manager_frontend::{DownloadManagerSignal, DownloadStatus};
use crate::download_manager::downloadable::Downloadable;
use crate::download_manager::util::download_thread_control_flag::{
DownloadThreadControl, DownloadThreadControlFlag,
@ -212,6 +212,7 @@ impl GameDownloadAgent {
let file = OpenOptions::new()
.read(true)
.write(true)
.truncate(true)
.create(true)
.open(path.clone())
.unwrap();
@ -267,7 +268,7 @@ impl GameDownloadAgent {
let completed_indexes_loop_arc = completed_contexts.clone();
let contexts = self.contexts.lock().unwrap();
debug!("{:#?}", contexts);
debug!("{contexts:#?}");
pool.scope(|scope| {
let client = &reqwest::blocking::Client::new();
let context_map = self.context_map.lock().unwrap();
@ -325,7 +326,7 @@ impl GameDownloadAgent {
);
}
Err(e) => {
error!("{}", e);
error!("{e}");
sender.send(DownloadManagerSignal::Error(e)).unwrap();
}
}
@ -352,8 +353,7 @@ impl GameDownloadAgent {
context_map_lock
.get(&x.checksum)
.cloned()
.or(Some(false))
.unwrap(),
.unwrap_or(false),
)
})
.collect::<Vec<(String, bool)>>();
@ -409,7 +409,7 @@ impl Downloadable for GameDownloadAgent {
.emit("download_error", error.to_string())
.unwrap();
error!("error while managing download: {}", error);
error!("error while managing download: {error}");
let mut handle = borrow_db_mut_checked();
handle

View File

@ -6,12 +6,12 @@ use crate::error::application_download_error::ApplicationDownloadError;
use crate::error::remote_access_error::RemoteAccessError;
use crate::games::downloads::manifest::DropDownloadContext;
use crate::remote::auth::generate_authorization_header;
use log::{debug, info, warn};
use log::{debug, warn};
use md5::{Context, Digest};
use reqwest::blocking::{RequestBuilder, Response};
use std::fs::{set_permissions, Permissions};
use std::io::{ErrorKind, Read};
use std::io::Read;
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
use std::{
@ -41,9 +41,8 @@ impl DropWriter<File> {
impl Write for DropWriter<File> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.hasher.write_all(buf).map_err(|e| {
io::Error::new(
ErrorKind::Other,
format!("Unable to write to hasher: {}", e),
io::Error::other(
format!("Unable to write to hasher: {e}"),
)
})?;
self.destination.write(buf)
@ -102,7 +101,7 @@ impl<'a> DropDownloadPipeline<'a, Response, File> {
if current_size > self.size {
let over = current_size - self.size;
warn!("server sent too many bytes... {} over", over);
warn!("server sent too many bytes... {over} over");
bytes_read -= over;
current_size = self.size;
}

View File

@ -43,7 +43,7 @@ impl DropData {
let mut file = match File::open(base_path.join(DROP_DATA_PATH)) {
Ok(file) => file,
Err(_) => {
debug!("Generating new dropdata for game {}", game_id);
debug!("Generating new dropdata for game {game_id}");
return DropData::new(game_id, game_version, base_path);
}
};
@ -52,7 +52,7 @@ impl DropData {
match file.read_to_end(&mut s) {
Ok(_) => {}
Err(e) => {
error!("{}", e);
error!("{e}");
return DropData::new(game_id, game_version, base_path);
}
};
@ -60,7 +60,7 @@ impl DropData {
match native_model::rmp_serde_1_3::RmpSerde::decode(s) {
Ok(manifest) => manifest,
Err(e) => {
warn!("{}", e);
warn!("{e}");
DropData::new(game_id, game_version, base_path)
}
}
@ -74,14 +74,14 @@ impl DropData {
let mut file = match File::create(self.base_path.join(DROP_DATA_PATH)) {
Ok(file) => file,
Err(e) => {
error!("{}", e);
error!("{e}");
return;
}
};
match file.write_all(&manifest_raw) {
Ok(_) => {}
Err(e) => error!("{}", e),
Err(e) => error!("{e}"),
};
}
pub fn set_contexts(&self, completed_contexts: &[(String, bool)]) {

View File

@ -11,7 +11,7 @@ use rayon::ThreadPoolBuilder;
use crate::{
database::db::borrow_db_checked,
download_manager::{
download_manager::DownloadManagerSignal,
download_manager_frontend::DownloadManagerSignal,
util::{
download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag},
progress_object::{ProgressHandle, ProgressObject},
@ -19,7 +19,6 @@ use crate::{
},
error::application_download_error::ApplicationDownloadError,
games::downloads::{drop_data::DropData, manifest::DropDownloadContext},
remote::{auth::generate_authorization_header, requests::make_request},
};
pub fn game_validate_logic(
@ -41,40 +40,15 @@ pub fn game_validate_logic(
.build()
.unwrap();
debug!("{:#?}", contexts);
debug!("{contexts:#?}");
let invalid_chunks = Arc::new(boxcar::Vec::new());
pool.scope(|scope| {
let client = &reqwest::blocking::Client::new();
for (index, context) in contexts.iter().enumerate() {
let client = client.clone();
let current_progress = progress.get(index);
let progress_handle = ProgressHandle::new(current_progress, progress.clone());
let invalid_chunks_scoped = invalid_chunks.clone();
let sender = sender.clone();
let request = match make_request(
&client,
&["/api/v1/client/chunk"],
&[
("id", &context.game_id),
("version", &context.version),
("name", &context.file_name),
("chunk", &context.index.to_string()),
],
|r| r.header("Authorization", generate_authorization_header()),
) {
Ok(request) => request,
Err(e) => {
sender
.send(DownloadManagerSignal::Error(
ApplicationDownloadError::Communication(e),
))
.unwrap();
continue;
}
};
scope.spawn(move |_| {
match validate_game_chunk(context, control_flag, progress_handle) {
Ok(true) => {
@ -91,7 +65,7 @@ pub fn game_validate_logic(
invalid_chunks_scoped.push(context.checksum.clone());
}
Err(e) => {
error!("{}", e);
error!("{e}");
sender.send(DownloadManagerSignal::Error(e)).unwrap();
}
}