From d2ea209de7cae3bdd5ddf9fdce01b2def3af5ba3 Mon Sep 17 00:00:00 2001 From: Muhamad Azamy Date: Thu, 28 Sep 2023 11:04:56 +0200 Subject: [PATCH] running clippy --- src/fs/mod.rs | 4 +++- src/fungi/meta.rs | 2 +- src/store/dir.rs | 6 ++---- src/store/mod.rs | 7 ++++++- src/store/zdb.rs | 7 ++----- src/unpack.rs | 12 +++++++++--- 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/fs/mod.rs b/src/fs/mod.rs index 0234ebb..6e2c2ce 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -85,7 +85,7 @@ where while let Some(req) = session.next_request().await? { let fs = self.clone(); - let _: JoinHandle> = task::spawn(async move { + let handler: JoinHandle> = task::spawn(async move { let result = match req.operation()? { Operation::Lookup(op) => fs.lookup(&req, op).await, Operation::Getattr(op) => fs.getattr(&req, op).await, @@ -105,6 +105,8 @@ where Ok(()) }); + + drop(handler); } Ok(()) diff --git a/src/fungi/meta.rs b/src/fungi/meta.rs index cecf5a8..58b638c 100644 --- a/src/fungi/meta.rs +++ b/src/fungi/meta.rs @@ -293,7 +293,7 @@ impl Reader { WalkItem(path, node): &WalkItem, visitor: &mut W, ) -> Result<()> { - if visitor.visit(&path, node).await? == Walk::Break { + if visitor.visit(path, node).await? == Walk::Break { return Ok(()); } diff --git a/src/store/dir.rs b/src/store/dir.rs index 0ee1271..9f78cad 100644 --- a/src/store/dir.rs +++ b/src/store/dir.rs @@ -1,9 +1,7 @@ -use super::{Error, Result, Route, Store}; -use futures::Future; +use super::{Error, FactoryFuture, Result, Route, Store}; use std::io::ErrorKind; use std::os::unix::prelude::OsStrExt; use std::path::PathBuf; -use std::pin::Pin; use tokio::fs; use url; @@ -18,7 +16,7 @@ async fn make_inner(url: String) -> Result> { Ok(Box::new(DirStore::new(u.path()).await?)) } -pub fn make(url: &str) -> Pin>>>> { +pub fn make(url: &str) -> FactoryFuture { Box::pin(make_inner(url.into())) } diff --git a/src/store/mod.rs b/src/store/mod.rs index 689779f..91f008d 100644 --- a/src/store/mod.rs +++ b/src/store/mod.rs @@ -99,7 +99,12 @@ pub trait Store: Send + Sync + 'static { /// The store factory works as a factory for a specific store /// this is only needed to be able dynamically create different types /// of stores based only on scheme of the store url. -pub type Factory = fn(u: &str) -> Pin>>>>; +/// the Factory returns a factory future that resolved to a Box +pub type Factory = fn(u: &str) -> FactoryFuture; + +/// FactoryFuture is a future that resolves to a Result> this +/// is returned by a factory function like above +pub type FactoryFuture = Pin>>>>; /// Router holds a set of shards (stores) where each store can be configured to serve /// a range of hashes. diff --git a/src/store/zdb.rs b/src/store/zdb.rs index 6d9486f..7e6fcca 100644 --- a/src/store/zdb.rs +++ b/src/store/zdb.rs @@ -1,6 +1,4 @@ -use std::pin::Pin; - -use super::{Error, Result, Route, Store}; +use super::{Error, FactoryFuture, Result, Route, Store}; use anyhow::Context; use bb8_redis::{ @@ -11,7 +9,6 @@ use bb8_redis::{ }, RedisConnectionManager, }; -use futures::Future; #[derive(Debug)] struct WithNamespace { @@ -96,7 +93,7 @@ async fn make_inner(url: String) -> Result> { Ok(Box::from(ZdbStore { url, pool })) } -pub fn make(url: &str) -> Pin>>>> { +pub fn make(url: &str) -> FactoryFuture { Box::pin(make_inner(url.into())) } diff --git a/src/unpack.rs b/src/unpack.rs index f7052dd..cddb3fa 100644 --- a/src/unpack.rs +++ b/src/unpack.rs @@ -1,5 +1,4 @@ use crate::cache::Cache; -use crate::fungi::meta::{Block, Mode}; use crate::fungi::{ meta::{FileType, Inode, Result, Walk, WalkVisitor}, Reader, @@ -10,8 +9,7 @@ use nix::unistd::{fchownat, FchownatFlags, Gid, Uid}; use std::fs::Permissions; use std::os::unix::ffi::OsStrExt; use std::os::unix::fs::PermissionsExt; -use std::path::{Path, PathBuf}; -use std::sync::Arc; +use std::path::Path; use std::{ffi::OsStr, fs}; use tokio::fs::OpenOptions; @@ -120,6 +118,12 @@ where } } +/* +TODO: parallel download ? + +this is a download worker that can be used in a worker pool to download files +in parallel + struct Downloader where S: Store, @@ -176,3 +180,5 @@ where } } } + +*/