From 99c224586a2e08fd2ca791226e84c627fc526f54 Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 22 Apr 2022 18:22:24 +0200 Subject: [PATCH] Fix more clippy warnings Signed-off-by: trivernis --- mediarepo-daemon/mediarepo-core/src/utils.rs | 4 ++-- .../mediarepo-socket/src/namespaces/files/sorting.rs | 2 +- .../mediarepo-worker/src/jobs/calculate_sizes.rs | 6 +++--- mediarepo-daemon/mediarepo-worker/src/lib.rs | 2 +- mediarepo-daemon/src/utils.rs | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mediarepo-daemon/mediarepo-core/src/utils.rs b/mediarepo-daemon/mediarepo-core/src/utils.rs index 04d6b89..12d6bd9 100644 --- a/mediarepo-daemon/mediarepo-core/src/utils.rs +++ b/mediarepo-daemon/mediarepo-core/src/utils.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use futures::future; use tokio::fs::{self, OpenOptions}; @@ -16,7 +16,7 @@ pub fn parse_namespace_and_tag(norm_tag: String) -> (Option, String) { } /// Parses all tags from a file -pub async fn parse_tags_file(path: PathBuf) -> RepoResult, String)>> { +pub async fn parse_tags_file(path: &Path) -> RepoResult, String)>> { let file = OpenOptions::new().read(true).open(path).await?; let mut lines = BufReader::new(file).lines(); let mut tags = Vec::new(); diff --git a/mediarepo-daemon/mediarepo-socket/src/namespaces/files/sorting.rs b/mediarepo-daemon/mediarepo-socket/src/namespaces/files/sorting.rs index 80c87bf..745ffed 100644 --- a/mediarepo-daemon/mediarepo-socket/src/namespaces/files/sorting.rs +++ b/mediarepo-daemon/mediarepo-socket/src/namespaces/files/sorting.rs @@ -176,7 +176,7 @@ fn adjust_for_dir(ordering: Ordering, direction: &SortDirection) -> Ordering { } } -fn compare_tag_lists(list_a: &Vec, list_b: &Vec) -> Ordering { +fn compare_tag_lists(list_a: &[String], list_b: &[String]) -> Ordering { let first_diff = list_a.iter().zip(list_b.iter()).find(|(a, b)| *a != *b); if let Some(diff) = first_diff { if let (Some(num_a), Some(num_b)) = (diff.0.parse::().ok(), diff.1.parse::().ok()) diff --git a/mediarepo-daemon/mediarepo-worker/src/jobs/calculate_sizes.rs b/mediarepo-daemon/mediarepo-worker/src/jobs/calculate_sizes.rs index d9ce393..b1e2821 100644 --- a/mediarepo-daemon/mediarepo-worker/src/jobs/calculate_sizes.rs +++ b/mediarepo-daemon/mediarepo-worker/src/jobs/calculate_sizes.rs @@ -6,7 +6,7 @@ use mediarepo_core::mediarepo_api::types::repo::SizeType; use mediarepo_core::settings::Settings; use mediarepo_core::utils::get_folder_size; use mediarepo_logic::dao::repo::Repo; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::Arc; use tokio::fs; use tokio::sync::broadcast::{self, Sender}; @@ -72,11 +72,11 @@ impl Job for CalculateSizesJob { async fn calculate_size( size_type: &SizeType, repo: &Repo, - repo_path: &PathBuf, + repo_path: &Path, settings: &Settings, ) -> RepoResult { let size = match &size_type { - SizeType::Total => get_folder_size(repo_path.clone()).await?, + SizeType::Total => get_folder_size(repo_path.to_path_buf()).await?, SizeType::FileFolder => repo.get_main_store_size().await?, SizeType::ThumbFolder => repo.get_thumb_store_size().await?, SizeType::DatabaseFile => { diff --git a/mediarepo-daemon/mediarepo-worker/src/lib.rs b/mediarepo-daemon/mediarepo-worker/src/lib.rs index 598c4b3..d85750b 100644 --- a/mediarepo-daemon/mediarepo-worker/src/lib.rs +++ b/mediarepo-daemon/mediarepo-worker/src/lib.rs @@ -1,5 +1,5 @@ use crate::job_dispatcher::JobDispatcher; -use crate::jobs::{CheckIntegrityJob, MigrateCDsJob, VacuumJob}; +use crate::jobs::{CheckIntegrityJob, MigrateCDsJob}; use mediarepo_core::error::RepoError; use mediarepo_core::tokio_graceful_shutdown::Toplevel; use mediarepo_logic::dao::repo::Repo; diff --git a/mediarepo-daemon/src/utils.rs b/mediarepo-daemon/src/utils.rs index 130947a..80716f2 100644 --- a/mediarepo-daemon/src/utils.rs +++ b/mediarepo-daemon/src/utils.rs @@ -1,14 +1,14 @@ -use std::path::PathBuf; +use std::path::Path; use tokio::fs; use mediarepo_core::error::RepoResult; -use mediarepo_core::settings::{PathSettings, Settings}; use mediarepo_core::settings::v1::SettingsV1; +use mediarepo_core::settings::{PathSettings, Settings}; use mediarepo_logic::dao::repo::Repo; /// Loads the settings from a toml path -pub fn load_settings(root_path: &PathBuf) -> RepoResult { +pub fn load_settings(root_path: &Path) -> RepoResult { let contents = std::fs::read_to_string(root_path.join("repo.toml"))?; if let Ok(settings_v1) = SettingsV1::from_toml_string(&contents) { @@ -21,7 +21,7 @@ pub fn load_settings(root_path: &PathBuf) -> RepoResult { } } -pub async fn get_repo(root_path: &PathBuf, path_settings: &PathSettings) -> RepoResult { +pub async fn get_repo(root_path: &Path, path_settings: &PathSettings) -> RepoResult { Repo::connect( format!( "sqlite://{}", @@ -33,7 +33,7 @@ pub async fn get_repo(root_path: &PathBuf, path_settings: &PathSettings) -> Repo .await } -pub async fn create_paths_for_repo(root: &PathBuf, settings: &PathSettings) -> RepoResult<()> { +pub async fn create_paths_for_repo(root: &Path, settings: &PathSettings) -> RepoResult<()> { if !root.exists() { fs::create_dir_all(&root).await?; }