From 76cbc85032965cea0cb9188b21900f3d3e683bd7 Mon Sep 17 00:00:00 2001 From: cy Date: Mon, 28 Apr 2025 21:39:14 -0400 Subject: [PATCH] use hashset for closure --- src/path_info.rs | 3 ++- src/push.rs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/path_info.rs b/src/path_info.rs index 0698533..1e1282d 100644 --- a/src/path_info.rs +++ b/src/path_info.rs @@ -13,7 +13,7 @@ use url::Url; use crate::store::Store; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct PathInfo { pub path: StorePath, pub signatures: Vec, @@ -59,6 +59,7 @@ impl PathInfo { .context("query pathinfo for path") } + // TODO: skip call to query_path_info and return Vec? pub async fn get_closure(&self, store: &Store) -> Result> { let futs = store .compute_fs_closure(self.path.clone()) diff --git a/src/push.rs b/src/push.rs index 5f7a591..bf25ea1 100644 --- a/src/push.rs +++ b/src/push.rs @@ -1,4 +1,5 @@ use std::{ + collections::HashSet, fs, iter::once, path::PathBuf, @@ -21,7 +22,7 @@ use crate::{PushArgs, path_info::PathInfo, store::Store, uploader::Uploader}; pub struct Push { upstream_caches: Vec, - store_paths: Arc>>, + store_paths: Arc>>, signing_key: SigningKey, store: Arc, s3: Arc, @@ -61,7 +62,7 @@ impl Push { Ok(Self { upstream_caches: upstreams, - store_paths: Arc::new(RwLock::new(Vec::new())), + store_paths: Arc::new(RwLock::new(HashSet::new())), signing_key, store: Arc::new(store), s3: Arc::new(s3_builder.build()?),