File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ impl DocBuilder {
12
12
/// Returns the number of crates added
13
13
pub fn get_new_crates ( & mut self ) -> Result < usize > {
14
14
let conn = connect_db ( ) ?;
15
- let ( mut changes, oid) = self . index . diff ( ) . peek_changes ( ) ?;
15
+ let diff = self . index . diff ( ) ?;
16
+ let ( mut changes, oid) = diff. peek_changes ( ) ?;
16
17
let mut crates_added = 0 ;
17
18
18
19
// I believe this will fix ordering of queue if we get more than one crate from changes
@@ -58,7 +59,7 @@ impl DocBuilder {
58
59
}
59
60
}
60
61
61
- self . index . diff ( ) . set_last_seen_reference ( oid) ?;
62
+ diff. set_last_seen_reference ( oid) ?;
62
63
63
64
Ok ( crates_added)
64
65
}
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ use url::Url;
4
4
5
5
use self :: api:: Api ;
6
6
use crate :: error:: Result ;
7
+ use failure:: ResultExt ;
7
8
8
9
pub ( crate ) mod api;
9
10
10
11
pub ( crate ) struct Index {
11
- diff : crates_index_diff:: Index ,
12
12
path : PathBuf ,
13
13
api : Api ,
14
14
}
@@ -41,14 +41,17 @@ fn load_config(repo: &git2::Repository) -> Result<IndexConfig> {
41
41
impl Index {
42
42
pub ( crate ) fn new ( path : impl AsRef < Path > ) -> Result < Self > {
43
43
let path = path. as_ref ( ) . to_owned ( ) ;
44
- let diff = crates_index_diff:: Index :: from_path_or_cloned ( & path) ?;
45
- let config = load_config ( diff. repository ( ) ) ?;
46
- let api = Api :: new ( config. api ) ?;
47
- Ok ( Self { diff, path, api } )
44
+ let diff = crates_index_diff:: Index :: from_path_or_cloned ( & path)
45
+ . context ( "initialising registry index repository" ) ?;
46
+ let config = load_config ( diff. repository ( ) ) . context ( "loading registry config" ) ?;
47
+ let api = Api :: new ( config. api ) . context ( "initialising registry api client" ) ?;
48
+ Ok ( Self { path, api } )
48
49
}
49
50
50
- pub ( crate ) fn diff ( & self ) -> & crates_index_diff:: Index {
51
- & self . diff
51
+ pub ( crate ) fn diff ( & self ) -> Result < crates_index_diff:: Index > {
52
+ let diff = crates_index_diff:: Index :: from_path_or_cloned ( & self . path )
53
+ . context ( "re-opening registry index for diff" ) ?;
54
+ Ok ( diff)
52
55
}
53
56
54
57
pub ( crate ) fn api ( & self ) -> & Api {
You can’t perform that action at this time.
0 commit comments