Skip to content

Commit 29f7e91

Browse files
committed
Use new Crate::from_slice constructor
1 parent 88e19e1 commit 29f7e91

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2018"
1212
log = "0.4"
1313
regex = "1"
1414
structopt = "0.3"
15-
crates-index = "0.15.0"
15+
crates-index = "0.15.1"
1616
crates-index-diff = "7"
1717
reqwest = { version = "0.10.6", features = ["blocking", "json"] } # TODO: Remove blocking when async is ready
1818
semver = { version = "0.9", features = ["serde"] }

src/index/crates.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crates_index::Crate;
22
use failure::ResultExt;
3-
use std::io::{Seek, SeekFrom, Write};
43

54
pub(crate) struct Crates {
65
repo: git2::Repository,
@@ -18,23 +17,16 @@ impl Crates {
1817
.find_commit(self.repo.refname_to_id("refs/remotes/origin/master")?)?
1918
.tree()?;
2019

21-
// crates_index doesn't publicly expose their slice constructor, so need to write each blob
22-
// to a file before loading it as a `Crate`.
23-
let mut tmp = tempfile::NamedTempFile::new()?;
24-
2520
let mut result = Ok(());
2621

2722
tree.walk(git2::TreeWalkMode::PreOrder, |_, entry| {
2823
result = (|| {
2924
if let Some(blob) = entry.to_object(&self.repo)?.as_blob() {
30-
tmp.write_all(blob.content())?;
31-
if let Ok(krate) = Crate::new(tmp.path()) {
25+
if let Ok(krate) = Crate::from_slice(blob.content()) {
3226
f(krate);
3327
} else {
3428
log::warn!("Not a crate '{}'", entry.name().unwrap());
3529
}
36-
tmp.as_file().set_len(0)?;
37-
tmp.seek(SeekFrom::Start(0))?;
3830
}
3931
Result::<(), failure::Error>::Ok(())
4032
})()

0 commit comments

Comments
 (0)