Skip to content

Commit

Permalink
Apply clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamadazmy committed Sep 20, 2023
1 parent 917f2d8 commit 00b2e3b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 241 deletions.
2 changes: 1 addition & 1 deletion src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where

// download given an open file, writes the content of the chunk to the file
async fn download(&self, file: &mut File, block: &Block) -> Result<u64> {
let data = self.store.get(&block).await?;
let data = self.store.get(block).await?;
file.write_all(&data).await?;

Ok(data.len() as u64)
Expand Down
4 changes: 2 additions & 2 deletions src/fungi/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl From<u32> for FileType {
}
}

static SCHEMA: &'static str = include_str!("../../schema/schema.sql");
static SCHEMA: &str = include_str!("../../schema/schema.sql");

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Mode {
}

pub fn file_type(&self) -> FileType {
(self.0 as u32 & TYPE_MASK).into()
(self.0 & TYPE_MASK).into()
}

pub fn permissions(&self) -> u32 {
Expand Down
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async fn scan<S: Store>(
rdev: m.rdev(),
ctime: m.ctime(),
mtime: m.mtime(),
data: data,
data,
..Default::default()
})
.await?;
Expand Down Expand Up @@ -228,8 +228,10 @@ mod test {
use tokio::io::AsyncWriteExt;

#[tokio::test]
async fn create_meta() {
async fn pack_unpack() {
const ROOT: &str = "/tmp/pack-unpack-test";
fs::remove_dir_all(ROOT).await.unwrap();

let root: PathBuf = ROOT.into();
let source = root.join("source");
fs::create_dir_all(&source).await.unwrap();
Expand Down Expand Up @@ -284,6 +286,8 @@ mod test {
unpack(&reader, &cache, root.join("destination"))
.await
.unwrap();

//TODO compare source and destination
}

struct WalkTest;
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async fn app(opts: Options) -> Result<()> {
.await
.context("failed to initialize metadata database")?;

let store = store::zdb::ZdbStoreFactory.new(&opts.storage_url).await?;
let store = store::zdb::ZdbStoreFactory.build(&opts.storage_url).await?;

let cache = cache::Cache::new(opts.cache, store);

Expand Down
6 changes: 3 additions & 3 deletions src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub trait Store: Send + Sync + 'static {
pub trait StoreFactory {
type Store: Store;

async fn new<U: AsRef<str> + Send>(&self, url: U) -> anyhow::Result<Self::Store>;
async fn build<U: AsRef<str> + Send>(&self, url: U) -> anyhow::Result<Self::Store>;
}

/// Router holds a set of shards (stores) where each store can be configured to serve
Expand All @@ -87,7 +87,7 @@ pub type Router = router::Router<Box<dyn Store>>;
#[async_trait::async_trait]
impl Store for Router {
async fn get(&self, key: &[u8]) -> Result<Vec<u8>> {
if key.len() == 0 {
if key.is_empty() {
return Err(Error::InvalidKey);
}
let mut errors = Vec::default();
Expand All @@ -107,7 +107,7 @@ impl Store for Router {
}

async fn set(&self, key: &[u8], blob: &[u8]) -> Result<()> {
if key.len() == 0 {
if key.is_empty() {
return Err(Error::InvalidKey);
}

Expand Down
7 changes: 3 additions & 4 deletions src/store/zdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ impl ZdbStoreFactory {
let addr = ConnectionAddr::Tcp(host.to_string(), u.port().unwrap_or(9900));
let ns: Option<String> = u
.path_segments()
.map(|s| s.last().map(|s| s.to_owned()))
.flatten();
.and_then(|s| s.last().map(|s| s.to_owned()));
(addr, ns)
}
None => (ConnectionAddr::Unix(u.path().into()), None),
Expand Down Expand Up @@ -78,12 +77,12 @@ impl ZdbStoreFactory {
impl StoreFactory for ZdbStoreFactory {
type Store = ZdbStore;

async fn new<U: AsRef<str> + Send>(&self, u: U) -> anyhow::Result<Self::Store> {
async fn build<U: AsRef<str> + Send>(&self, u: U) -> anyhow::Result<Self::Store> {
let url = u.as_ref().to_owned();
let (mut info, namespace) = self.get_connection_info(u)?;

let namespace = WithNamespace {
namespace: namespace,
namespace,
password: info.redis.password.take(),
};

Expand Down
228 changes: 0 additions & 228 deletions tests/integration_test.rs

This file was deleted.

0 comments on commit 00b2e3b

Please sign in to comment.