chore: Ran cargo clippy & cargo fmt

This commit is contained in:
quexeky
2025-01-20 08:55:19 +11:00
parent 7d4651db69
commit 92729701c3
26 changed files with 144 additions and 126 deletions

View File

@ -3,9 +3,7 @@ use std::sync::Mutex;
use tauri::AppHandle;
use crate::{
error::{
library_error::LibraryError, remote_access_error::RemoteAccessError,
},
error::{library_error::LibraryError, remote_access_error::RemoteAccessError},
games::library::{get_current_meta, uninstall_game_logic},
AppState,
};

View File

@ -1,7 +1,10 @@
use std::sync::{mpsc::SendError, Arc, Mutex};
use std::sync::{Arc, Mutex};
use crate::{
download_manager::{download_manager::DownloadManagerSignal, downloadable::Downloadable, internal_error::InternalError},
download_manager::{
download_manager::DownloadManagerSignal, downloadable::Downloadable,
internal_error::InternalError,
},
AppState,
};

View File

@ -1,6 +1,7 @@
use crate::auth::generate_authorization_header;
use crate::database::db::{
borrow_db_checked, set_game_status, ApplicationTransientStatus, DatabaseImpls, GameDownloadStatus
borrow_db_checked, set_game_status, ApplicationTransientStatus, DatabaseImpls,
GameDownloadStatus,
};
use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus};
use crate::download_manager::download_thread_control_flag::{
@ -18,7 +19,6 @@ use crate::DB;
use log::{debug, error, info};
use rayon::ThreadPoolBuilder;
use slice_deque::SliceDeque;
use std::collections::HashMap;
use std::fs::{create_dir_all, File};
use std::path::Path;
use std::sync::mpsc::Sender;
@ -275,17 +275,18 @@ impl GameDownloadAgent {
let sender = self.sender.clone();
// TODO: Error handling
let request = 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())
}).unwrap();
let request = 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()),
)
.unwrap();
scope.spawn(move |_| {
match download_game_chunk(context, &self.control_flag, progress_handle, request)
@ -315,10 +316,12 @@ impl GameDownloadAgent {
completed_contexts_lock.len()
};
// If we're not out of contexts, we're not done, so we don't fire completed
if completed_lock_len != contexts.len() {
info!("download agent for {} exited without completing", self.id.clone());
info!(
"download agent for {} exited without completing",
self.id.clone()
);
self.stored_manifest
.set_completed_contexts(self.completed_contexts.lock().unwrap().as_slice());
self.stored_manifest.write();

View File

@ -5,7 +5,7 @@ use crate::download_manager::progress_object::ProgressHandle;
use crate::error::application_download_error::ApplicationDownloadError;
use crate::error::remote_access_error::RemoteAccessError;
use crate::games::downloads::manifest::DropDownloadContext;
use log::{error, warn};
use log::warn;
use md5::{Context, Digest};
use reqwest::blocking::{RequestBuilder, Response};
@ -177,7 +177,6 @@ pub fn download_game_chunk(
set_permissions(ctx.path.clone(), permissions).unwrap();
}
let checksum = pipeline
.finish()
.map_err(|e| ApplicationDownloadError::IoError(e.kind()))?;

View File

@ -2,7 +2,7 @@ use std::fs::remove_dir_all;
use std::sync::Mutex;
use std::thread::spawn;
use log::{debug, error, info, warn};
use log::{debug, error, warn};
use serde::{Deserialize, Serialize};
use tauri::Emitter;
use tauri::{AppHandle, Manager};
@ -139,9 +139,10 @@ pub fn fetch_game_logic(
return Ok(data);
}
let client = reqwest::blocking::Client::new();
let response = make_request(&client, &["/api/v1/game/", &id],&[], |r| {
let response = make_request(&client, &["/api/v1/game/", &id], &[], |r| {
r.header("Authorization", generate_authorization_header())
})?.send()?;
})?
.send()?;
if response.status() == 404 {
return Err(RemoteAccessError::GameNotFound);
@ -179,10 +180,14 @@ pub fn fetch_game_verion_options_logic(
state: tauri::State<'_, Mutex<AppState>>,
) -> Result<Vec<GameVersionOption>, RemoteAccessError> {
let client = reqwest::blocking::Client::new();
let response = make_request(&client, &["/api/v1/client/game/versions"], &[("id", &game_id)], |r| {
r.header("Authorization", generate_authorization_header())
})?.send()?;
let response = make_request(
&client,
&["/api/v1/client/game/versions"],
&[("id", &game_id)],
|r| r.header("Authorization", generate_authorization_header()),
)?
.send()?;
if response.status() != 200 {
let err = response.json().unwrap();

View File

@ -1,7 +1,4 @@
use crate::{
database::db::{borrow_db_checked, ApplicationTransientStatus, GameDownloadStatus},
DB,
};
use crate::database::db::{borrow_db_checked, ApplicationTransientStatus, GameDownloadStatus};
pub type GameStatusWithTransient = (
Option<GameDownloadStatus>,