fix: clippy lints

This commit is contained in:
DecDuck
2025-12-01 16:27:08 +11:00
parent bd2e44d4f0
commit fd65a0653f
5 changed files with 10 additions and 28 deletions
-3
View File
@@ -1,7 +1,6 @@
use std::{collections::HashMap, time::Instant};
use droplet_rs::versions::create_backend_constructor;
use log::info;
use reqwest::StatusCode;
use crate::{AppInitData, DownloadContext, remote::{LibraryBackend, fetch_download_context}, util::ErrorOption};
@@ -41,8 +40,6 @@ pub async fn create_download_context<'a>(
}
let download_context = DownloadContext {
library_id: context.library_id,
library_path: context.library_path,
chunk_lookup_table,
backend,
last_access: Instant::now(),
+9 -19
View File
@@ -1,15 +1,11 @@
use anyhow::{Result, anyhow};
use anyhow::Result;
use dashmap::DashMap;
use droplet_rs::versions::types::{VersionBackend, VersionFile};
use reqwest::header;
use simple_logger::SimpleLogger;
use std::{
collections::HashMap,
env::set_current_dir,
path::PathBuf,
str::FromStr,
sync::Arc,
time::{Duration, Instant},
collections::HashMap, env::set_current_dir, path::PathBuf, str::FromStr, sync::Arc,
time::Instant,
};
use tokio_util::io::ReaderStream;
@@ -23,10 +19,7 @@ use axum::{
};
use log::{error, info, warn};
use serde::Deserialize;
use tokio::{
sync::{OnceCell, Semaphore},
time::sleep,
};
use tokio::sync::{OnceCell, Semaphore};
use crate::{
download::create_download_context,
@@ -41,8 +34,6 @@ mod util;
static GLOBAL_CONTEXT_SEMAPHORE: Semaphore = Semaphore::const_new(1);
struct DownloadContext<'a> {
library_id: String,
library_path: String,
chunk_lookup_table: HashMap<String, (String, usize, usize)>,
backend: Box<dyn VersionBackend + Send + Sync + 'a>,
last_access: Instant,
@@ -57,7 +48,6 @@ struct AppInitData {
struct AppState<'a> {
token: OnceCell<AppInitData>,
context_cache: DashMap<(String, String), DownloadContext<'a>>,
working_context_cache: DashMap<(String, String), Semaphore>,
}
async fn serve_file(
@@ -155,10 +145,11 @@ async fn set_token(
let valid_library_sources = library_sources
.into_iter()
.filter(|v| match v.backend {
remote::LibraryBackend::Filesystem | remote::LibraryBackend::FlatFilesystem => true,
#[allow(unreachable_patterns)]
_ => false,
.filter(|v| {
matches!(
v.backend,
remote::LibraryBackend::Filesystem | remote::LibraryBackend::FlatFilesystem
)
})
.map(|v| {
let path = PathBuf::from_str(
@@ -206,7 +197,6 @@ async fn main() {
let shared_state = Arc::new(AppState {
token: OnceCell::new(),
context_cache: DashMap::new(),
working_context_cache: DashMap::new(),
});
let app = Router::new()
-2
View File
@@ -4,9 +4,7 @@ use serde::Deserialize;
#[derive(Deserialize)]
pub struct DropChunk {
pub permissions: usize,
pub ids: Vec<String>,
pub checksums: Vec<String>,
pub lengths: Vec<usize>,
}
-3
View File
@@ -10,9 +10,7 @@ use crate::{manifest::DropletManifest, util::ErrorOption};
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ContextResponseBody {
timeout: String,
pub manifest: DropletManifest,
version_name: String,
pub library_id: String,
pub library_path: String,
}
@@ -88,7 +86,6 @@ pub enum LibraryBackend {
pub struct LibrarySource {
pub options: serde_json::Value,
pub id: String,
name: String,
pub backend: LibraryBackend
}
+1 -1
View File
@@ -1,5 +1,5 @@
use log::error;
use reqwest::{StatusCode, Url};
use reqwest::StatusCode;
#[derive(Debug)]
pub struct ErrorOption(Result<StatusCode, anyhow::Error>);