mirror of https://github.com/zkat/cacache-rs.git
fix(index): make Entry use actual Integrity objects
This commit is contained in:
parent
fc067e95d9
commit
7ad0633c43
|
|
@ -94,7 +94,7 @@ dependencies = [
|
|||
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ssri 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ssri 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -434,12 +434,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ssri"
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -578,7 +580,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d"
|
||||
"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68"
|
||||
"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"
|
||||
"checksum ssri 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "476c5b58680af254757d0d8cb1cb0020c98af1eca109a488b316bf5b1a613978"
|
||||
"checksum ssri 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca84a10ff31fe24ceb1bff0c89af7c1104f024a8eda1e563ade3f6046f02a5c4"
|
||||
"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe"
|
||||
"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
|
||||
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ authors = ["Kat Marchán <kzm@zkat.tech>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
ssri = "1.1.0"
|
||||
ssri = "1.2.0"
|
||||
hex = "0.3.2"
|
||||
atomicwrites = "0.2.2"
|
||||
tempfile = "3.0.8"
|
||||
|
|
|
|||
12
src/index.rs
12
src/index.rs
|
|
@ -19,8 +19,7 @@ const INDEX_VERSION: &str = "5";
|
|||
#[derive(PartialEq, Debug)]
|
||||
pub struct Entry {
|
||||
key: String,
|
||||
// TODO - implement Serialize for Integrity!
|
||||
integrity: String,
|
||||
integrity: Integrity,
|
||||
time: u128,
|
||||
size: u128,
|
||||
metadata: Value,
|
||||
|
|
@ -109,9 +108,14 @@ pub fn find(cache: &Path, key: &str) -> Result<Option<Entry>, Error> {
|
|||
Ok(bucket_entries(&bucket)?.into_iter().fold(None, |acc, entry| {
|
||||
if entry.key == key {
|
||||
if entry.integrity.is_some() {
|
||||
let integrity = entry.integrity.unwrap();
|
||||
let integrity: Integrity = match integrity.parse() {
|
||||
Ok(sri) => sri,
|
||||
_ => return acc
|
||||
};
|
||||
Some(Entry {
|
||||
key: entry.key,
|
||||
integrity: entry.integrity.unwrap(),
|
||||
integrity,
|
||||
size: entry.size,
|
||||
time: entry.time,
|
||||
metadata: entry.metadata
|
||||
|
|
@ -233,7 +237,7 @@ mod tests {
|
|||
entry,
|
||||
Entry {
|
||||
key: String::from("hello"),
|
||||
integrity: sri.to_string(),
|
||||
integrity: sri,
|
||||
time,
|
||||
size: 0,
|
||||
metadata: json!(null)
|
||||
|
|
|
|||
Loading…
Reference in New Issue