Skip to content

Commit

Permalink
running clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamadazmy committed Sep 28, 2023
1 parent e804063 commit d2ea209
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
while let Some(req) = session.next_request().await? {
let fs = self.clone();

let _: JoinHandle<Result<()>> = task::spawn(async move {
let handler: JoinHandle<Result<()>> = 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,
Expand All @@ -105,6 +105,8 @@ where

Ok(())
});

drop(handler);
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/fungi/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}

Expand Down
6 changes: 2 additions & 4 deletions src/store/dir.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -18,7 +16,7 @@ async fn make_inner(url: String) -> Result<Box<dyn Store>> {
Ok(Box::new(DirStore::new(u.path()).await?))
}

pub fn make(url: &str) -> Pin<Box<dyn Future<Output = Result<Box<dyn Store>>>>> {
pub fn make(url: &str) -> FactoryFuture {
Box::pin(make_inner(url.into()))
}

Expand Down
7 changes: 6 additions & 1 deletion src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<dyn Future<Output = Result<Box<dyn Store>>>>>;
/// the Factory returns a factory future that resolved to a Box<dyn Store>
pub type Factory = fn(u: &str) -> FactoryFuture;

/// FactoryFuture is a future that resolves to a Result<Box<dyn Store>> this
/// is returned by a factory function like above
pub type FactoryFuture = Pin<Box<dyn Future<Output = Result<Box<dyn Store>>>>>;

/// Router holds a set of shards (stores) where each store can be configured to serve
/// a range of hashes.
Expand Down
7 changes: 2 additions & 5 deletions src/store/zdb.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -11,7 +9,6 @@ use bb8_redis::{
},
RedisConnectionManager,
};
use futures::Future;

#[derive(Debug)]
struct WithNamespace {
Expand Down Expand Up @@ -96,7 +93,7 @@ async fn make_inner(url: String) -> Result<Box<dyn Store>> {
Ok(Box::from(ZdbStore { url, pool }))
}

pub fn make(url: &str) -> Pin<Box<dyn Future<Output = Result<Box<dyn Store>>>>> {
pub fn make(url: &str) -> FactoryFuture {
Box::pin(make_inner(url.into()))
}

Expand Down
12 changes: 9 additions & 3 deletions src/unpack.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::cache::Cache;
use crate::fungi::meta::{Block, Mode};
use crate::fungi::{
meta::{FileType, Inode, Result, Walk, WalkVisitor},
Reader,
Expand All @@ -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;

Expand Down Expand Up @@ -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<S>
where
S: Store,
Expand Down Expand Up @@ -176,3 +180,5 @@ where
}
}
}
*/

0 comments on commit d2ea209

Please sign in to comment.