summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKornel <kornel@geekhood.net>2020-03-06 14:55:44 +0000
committerKornel <kornel@geekhood.net>2020-03-06 14:55:44 +0000
commit9754de633660203ac7f2e289d2a103110ff67de2 (patch)
treeb6db382dbd9f2ad2cf51b0bdc2ef678ed056140e
parent57b4083b5924b51caf6ab934913a0ba5f9df5b2f (diff)
Smaller crates index
-rw-r--r--deps_index/Cargo.toml4
-rw-r--r--deps_index/src/index.rs5
-rw-r--r--deps_index/src/lib.rs2
3 files changed, 8 insertions, 3 deletions
diff --git a/deps_index/Cargo.toml b/deps_index/Cargo.toml
index 1c6a479..4c024b4 100644
--- a/deps_index/Cargo.toml
+++ b/deps_index/Cargo.toml
@@ -1,13 +1,13 @@
[package]
name = "deps_index"
-version = "0.1.0"
+version = "0.1.1"
authors = ["Kornel <kornel@geekhood.net>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-crates-index = "0.14"
+crates-index = { git = "https://github.com/frewsxcv/rust-crates-index", version = "0.14.1", branch = "smol" }
rich_crate = { path = "../rich_crate", version = "0.5" }
repo_url = { path = "../repo_url", version = "0.3.0" }
serde = "1.0.104"
diff --git a/deps_index/src/index.rs b/deps_index/src/index.rs
index 9ff6bcd..c55d9fd 100644
--- a/deps_index/src/index.rs
+++ b/deps_index/src/index.rs
@@ -139,12 +139,15 @@ pub struct Index {
impl Index {
pub fn new(data_dir: &Path) -> Result<Self, DepsErr> {
let crates_io_index = crates_index::Index::new(data_dir.join("index"));
- let indexed_crates = crates_io_index.crate_index_paths().par_bridge()
+ let indexed_crates: FxHashMap<_,_> = crates_io_index.crate_index_paths().par_bridge()
.filter_map(|path| {
let c = crates_index::Crate::new_checked(path).ok()?;
Some((c.name().to_ascii_lowercase().into(), c))
})
.collect();
+ if indexed_crates.len() < 35000 {
+ return Err(DepsErr::IndexBroken);
+ }
Ok(Self {
git_index: GitIndex::new(data_dir)?,
cache: RwLock::new(FxHashMap::with_capacity_and_hasher(5000, Default::default())),
diff --git a/deps_index/src/lib.rs b/deps_index/src/lib.rs
index 28aed0c..060bd02 100644
--- a/deps_index/src/lib.rs
+++ b/deps_index/src/lib.rs
@@ -25,6 +25,8 @@ pub enum DepsErr {
Stopped,
#[fail(display = "Deps stats timeout")]
DepsNotAvailable,
+ #[fail(display = "Index is empty or parsing failed")]
+ IndexBroken,
#[fail(display = "Crate timeout")]
GitIndexFile(PathBuf, String),
#[fail(display = "Git crate '{:?}' can't be indexed, because it's not on the list", _0)]