mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
Clippy the entire repo (#2195)
* fix(clippy): for the entire repo * fix: make function non-const fn
This commit is contained in:
parent
6d5bf4a013
commit
6761980503
@ -23,7 +23,7 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use chrono::{DateTime, FixedOffset, Utc};
|
||||
use directories::UserDirs;
|
||||
use rspc::{self, alpha::AlphaRouter, ErrorCode};
|
||||
use rspc::{alpha::AlphaRouter, ErrorCode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
use tracing::{debug, error};
|
||||
|
||||
@ -63,8 +63,7 @@ pub(crate) fn mount() -> AlphaRouter<Ctx> {
|
||||
MaybeUndefined::Undefined,
|
||||
Some(true),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
|
||||
@ -4,8 +4,8 @@ use tracing::info;
|
||||
|
||||
use crate::cloud::sync::err_break;
|
||||
|
||||
//// Responsible for taking sync operations received from the cloud,
|
||||
//// and applying them to the local database via the sync system's ingest actor.
|
||||
// Responsible for taking sync operations received from the cloud,
|
||||
// and applying them to the local database via the sync system's ingest actor.
|
||||
|
||||
pub async fn run_actor(sync: Arc<sd_core_sync::Manager>, notify: Arc<Notify>) {
|
||||
loop {
|
||||
|
||||
@ -21,8 +21,9 @@ use serde_json::to_vec;
|
||||
use tokio::{sync::Notify, time::sleep};
|
||||
use uuid::Uuid;
|
||||
|
||||
//// Responsible for downloading sync operations from the cloud to be processed by the ingester
|
||||
// Responsible for downloading sync operations from the cloud to be processed by the ingester
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn run_actor(
|
||||
library: Arc<Library>,
|
||||
libraries: Arc<Libraries>,
|
||||
|
||||
@ -10,7 +10,7 @@ use tokio::time::sleep;
|
||||
|
||||
use super::err_break;
|
||||
|
||||
//// Responsible for sending its instance's sync operations to the cloud.
|
||||
// Responsible for sending its instance's sync operations to the cloud.
|
||||
|
||||
pub async fn run_actor(
|
||||
library_id: Uuid,
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
// use sd_crypto::types::{DerivationContext, MagicBytes};
|
||||
|
||||
pub mod error;
|
||||
// pub mod error;
|
||||
// pub use error::{KeyManagerError, Result};
|
||||
|
||||
// pub mod keymanager;
|
||||
|
||||
@ -332,8 +332,7 @@ pub fn router(node: Arc<Node>) -> Router<()> {
|
||||
.parse()
|
||||
.expect("url was validated by Axum");
|
||||
|
||||
let request_upgrade_header =
|
||||
request.headers().get(header::UPGRADE).map(Clone::clone);
|
||||
let request_upgrade_header = request.headers().get(header::UPGRADE).cloned();
|
||||
let maybe_client_upgrade = request.extensions_mut().remove::<OnUpgrade>();
|
||||
|
||||
let mut response = match operations::remote_rspc(
|
||||
|
||||
@ -11,6 +11,7 @@ use tokio_util::sync::PollSender;
|
||||
pub struct MpscToAsyncWrite(PollSender<io::Result<Bytes>>);
|
||||
|
||||
impl MpscToAsyncWrite {
|
||||
#[allow(dead_code)]
|
||||
pub fn new(sender: PollSender<io::Result<Bytes>>) -> Self {
|
||||
Self(sender)
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ use sd_utils::{
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use rspc::{self, ErrorCode};
|
||||
use rspc::ErrorCode;
|
||||
use thiserror::Error;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
||||
@ -701,7 +701,6 @@ mod tests {
|
||||
use chrono::Utc;
|
||||
use globset::{Glob, GlobSetBuilder};
|
||||
use tempfile::{tempdir, TempDir};
|
||||
use tokio::fs;
|
||||
// use tracing_test::traced_test;
|
||||
|
||||
impl PartialEq for WalkedEntry {
|
||||
|
||||
@ -15,7 +15,7 @@ use std::{
|
||||
use chrono::{DateTime, Utc};
|
||||
use futures::future::try_join_all;
|
||||
use globset::{Glob, GlobSet, GlobSetBuilder};
|
||||
use rmp_serde::{self, decode, encode};
|
||||
use rmp_serde::{decode, encode};
|
||||
use rspc::ErrorCode;
|
||||
use serde::{de, ser, Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
@ -622,7 +622,6 @@ pub fn generate_pub_id() -> Uuid {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use tempfile::tempdir;
|
||||
use tokio::fs;
|
||||
|
||||
impl IndexerRule {
|
||||
pub fn new(name: String, default: bool, rules: Vec<RulePerKind>) -> Self {
|
||||
|
||||
@ -4,7 +4,6 @@ use std::str;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
use strum_macros::{Display, EnumIter};
|
||||
use sysinfo::SystemExt;
|
||||
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, Clone, Display, Copy, EnumIter, Type, Serialize, Deserialize, Eq, PartialEq)]
|
||||
|
||||
@ -22,7 +22,7 @@ use tokio::{
|
||||
fs::{self, OpenOptions},
|
||||
io::AsyncWriteExt,
|
||||
};
|
||||
use tracing::{trace, warn};
|
||||
use tracing::trace;
|
||||
|
||||
use super::{
|
||||
error::FileSystemJobsError, get_file_data_from_isolated_file_path, get_many_files_datas,
|
||||
@ -147,11 +147,11 @@ impl StatefulJob for OldFileEraserJobInit {
|
||||
.open(&step.full_path)
|
||||
.await
|
||||
.map_err(|e| FileIOError::from((&step.full_path, e)))?;
|
||||
let file_len = file
|
||||
.metadata()
|
||||
.await
|
||||
.map_err(|e| FileIOError::from((&step.full_path, e)))?
|
||||
.len();
|
||||
// let file_len = file
|
||||
// .metadata()
|
||||
// .await
|
||||
// .map_err(|e| FileIOError::from((&step.full_path, e)))?
|
||||
// .len();
|
||||
|
||||
trace!(
|
||||
"Overwriting file: {} with {} passes",
|
||||
|
||||
@ -17,7 +17,7 @@ use std::{
|
||||
|
||||
use async_channel as chan;
|
||||
use futures_concurrency::future::{Join, Race};
|
||||
use image::{self, imageops, DynamicImage, GenericImageView};
|
||||
use image::{imageops, DynamicImage, GenericImageView};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::{
|
||||
fs, io,
|
||||
|
||||
@ -14,11 +14,13 @@ const ONE_MINUTE: Duration = Duration::from_secs(60);
|
||||
|
||||
// Actor that can be invoked to find and delete objects with no matching file paths
|
||||
#[derive(Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct OrphanRemoverActor {
|
||||
tx: mpsc::Sender<()>,
|
||||
}
|
||||
|
||||
impl OrphanRemoverActor {
|
||||
#[allow(dead_code)]
|
||||
pub fn spawn(db: Arc<PrismaClient>) -> Self {
|
||||
let (tx, mut rx) = mpsc::channel(4);
|
||||
|
||||
@ -50,10 +52,12 @@ impl OrphanRemoverActor {
|
||||
Self { tx }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn invoke(&self) {
|
||||
self.tx.send(()).await.ok();
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
async fn process_clean_up(db: &PrismaClient) {
|
||||
loop {
|
||||
let Ok(objects_ids) = db
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::node::{HardwareModel, Platform};
|
||||
|
||||
use std::{collections::HashMap, env, str::FromStr};
|
||||
use std::{collections::HashMap, env, fmt::Display, str::FromStr};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
@ -89,20 +89,22 @@ impl OperatingSystem {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for OperatingSystem {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
OperatingSystem::Windows => "Windows".into(),
|
||||
OperatingSystem::Linux => "Linux".into(),
|
||||
OperatingSystem::MacOS => "MacOS".into(),
|
||||
OperatingSystem::Ios => "IOS".into(),
|
||||
OperatingSystem::Android => "Android".into(),
|
||||
impl Display for OperatingSystem {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let s = match self {
|
||||
OperatingSystem::Windows => "Windows",
|
||||
OperatingSystem::Linux => "Linux",
|
||||
OperatingSystem::MacOS => "MacOS",
|
||||
OperatingSystem::Ios => "IOS",
|
||||
OperatingSystem::Android => "Android",
|
||||
OperatingSystem::Other(s) => {
|
||||
let mut chars = s.chars();
|
||||
chars.next();
|
||||
chars.as_str().to_string()
|
||||
chars.as_str()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
f.write_str(s)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,12 +2,11 @@ use crate::api::search;
|
||||
|
||||
use sd_prisma::prisma::PrismaClient;
|
||||
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
use tracing::error;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
@ -8,16 +8,6 @@ use std::{
|
||||
sync::OnceLock,
|
||||
};
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
|
||||
#[cfg(target_os = "ios")]
|
||||
use icrate::{
|
||||
objc2::runtime::{Class, Object},
|
||||
objc2::{msg_send, sel},
|
||||
Foundation::{self, ns_string, NSFileManager, NSFileSystemSize, NSNumber, NSString},
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::{serde_as, DisplayFromStr};
|
||||
use specta::Type;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use sd_file_path_helper::{file_path_for_media_processor, IsolatedFilePathData};
|
||||
use sd_prisma::{
|
||||
prisma::{file_path, label, label_on_object, object, PrismaClient},
|
||||
@ -287,6 +289,7 @@ pub(super) async fn spawned_processing(
|
||||
.expect("critical error: image labeller batch processor unexpectedly closed");
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn spawned_process_single_file(
|
||||
model_and_session: Arc<OwnedRwLockReadGuard<ModelAndSession>>,
|
||||
(file_path_id, object_id): (file_path::id::Type, object::id::Type),
|
||||
|
||||
@ -177,13 +177,9 @@ impl Extension {
|
||||
path: impl AsRef<Path>,
|
||||
always_check_magic_bytes: bool,
|
||||
) -> Option<Self> {
|
||||
let Some(ext_str) = path.as_ref().extension().and_then(OsStr::to_str) else {
|
||||
return None;
|
||||
};
|
||||
let ext_str = path.as_ref().extension().and_then(OsStr::to_str)?;
|
||||
|
||||
let Some(ext) = Self::from_str(ext_str) else {
|
||||
return None;
|
||||
};
|
||||
let ext = Self::from_str(ext_str)?;
|
||||
|
||||
let Ok(ref mut file) = File::open(&path).await else {
|
||||
return None;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use std::{
|
||||
borrow::ToOwned,
|
||||
env::current_exe,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
@ -24,6 +24,7 @@ impl MediaDate {
|
||||
/// This iterates over all 3 pairs of time/offset tags in an attempt to create a UTC time.
|
||||
///
|
||||
/// If the above fails, we fall back to Naive time - if that's not present this is `Undefined`.
|
||||
#[must_use]
|
||||
pub fn from_reader(reader: &ExifReader) -> Option<Self> {
|
||||
let z = TIME_TAGS
|
||||
.into_iter()
|
||||
@ -47,7 +48,7 @@ impl MediaDate {
|
||||
|
||||
z.iter()
|
||||
.find(|x| matches!(x, Self::Utc(_) | Self::Naive(_)))
|
||||
.map(Clone::clone)
|
||||
.cloned()
|
||||
}
|
||||
|
||||
/// Returns the amount of non-leap seconds since the Unix Epoch (1970-01-01T00:00:00+00:00)
|
||||
|
||||
@ -38,6 +38,7 @@ const PROTOCOL: StreamProtocol = StreamProtocol::new("/sdp2p/1");
|
||||
|
||||
/// [libp2p::PeerId] for debugging purposes only.
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Libp2pPeerId(libp2p::PeerId);
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -225,7 +226,7 @@ async fn start(
|
||||
tokio::select! {
|
||||
Ok(event) = rx.recv_async() => match event {
|
||||
HookEvent::PeerExpiredBy(_, identity) => {
|
||||
let Some(peer) = p2p.peers.read().unwrap_or_else(PoisonError::into_inner).get(&identity).map(Clone::clone) else {
|
||||
let Some(peer) = p2p.peers.read().unwrap_or_else(PoisonError::into_inner).get(&identity).cloned() else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user