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

@ -41,7 +41,7 @@ pub fn create_collection(name: String) -> Result<Collection, RemoteAccessError>
let client = Client::new();
let base_url = DB.fetch_base_url();
let base_url = Url::parse(&format!("{}api/v1/client/collection/", base_url))?;
let base_url = Url::parse(&format!("{base_url}api/v1/client/collection/"))?;
let response = client
.post(base_url)

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();
}
}

View File

@ -11,7 +11,7 @@ use crate::database::db::{borrow_db_checked, borrow_db_mut_checked};
use crate::database::models::data::{
ApplicationTransientStatus, DownloadableMetadata, GameDownloadStatus, GameVersion,
};
use crate::download_manager::download_manager::DownloadStatus;
use crate::download_manager::download_manager_frontend::DownloadStatus;
use crate::error::library_error::LibraryError;
use crate::error::remote_access_error::RemoteAccessError;
use crate::games::state::{GameStatusManager, GameStatusWithTransient};
@ -85,7 +85,7 @@ pub fn fetch_library_logic(
if response.status() != 200 {
let err = response.json().unwrap();
warn!("{:?}", err);
warn!("{err:?}");
return Err(RemoteAccessError::InvalidResponse(err));
}
@ -106,8 +106,8 @@ pub fn fetch_library_logic(
}
// Add games that are installed but no longer in library
for (_, meta) in &db_handle.applications.installed_game_version {
if games.iter().find(|e| e.id == meta.id).is_some() {
for meta in db_handle.applications.installed_game_version.values() {
if games.iter().any(|e| e.id == meta.id) {
continue;
}
// We should always have a cache of the object
@ -187,7 +187,7 @@ pub fn fetch_game_logic(
}
if response.status() != 200 {
let err = response.json().unwrap();
warn!("{:?}", err);
warn!("{err:?}");
return Err(RemoteAccessError::InvalidResponse(err));
}
@ -263,7 +263,7 @@ pub fn fetch_game_verion_options_logic(
if response.status() != 200 {
let err = response.json().unwrap();
warn!("{:?}", err);
warn!("{err:?}");
return Err(RemoteAccessError::InvalidResponse(err));
}
@ -330,7 +330,7 @@ pub fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle)
let app_handle = app_handle.clone();
spawn(move || match remove_dir_all(install_dir) {
Err(e) => {
error!("{}", e);
error!("{e}");
}
Ok(_) => {
let mut db_handle = borrow_db_mut_checked();
@ -347,7 +347,7 @@ pub fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle)
drop(db_handle);
debug!("uninstalled game id {}", &meta.id);
app_handle.emit("update_library", {}).unwrap();
app_handle.emit("update_library", ()).unwrap();
push_game_update(
&app_handle,
@ -510,7 +510,7 @@ pub fn push_game_update(
) {
app_handle
.emit(
&format!("update_game/{}", game_id),
&format!("update_game/{game_id}"),
GameUpdateEvent {
game_id: game_id.clone(),
status,