Skip to content

Commit

Permalink
Expose /watched/ route
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Feb 21, 2018
1 parent 10cb6f5 commit 37f0a78
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/daemon/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ enum Route {
Downloading,
Deleted,
Watching,
Watched,
}


Expand Down Expand Up @@ -206,6 +207,9 @@ impl<S> server::Codec<S> for HttpCodec
Route::Watching => {
ok(serve_json(e, &self.tracking.get_watching()))
}
Route::Watched => {
ok(serve_json(e, &self.tracking.get_watched()))
}
Route::Cluster(ClusterRoute::Downloading) => {
#[derive(Serialize)]
pub struct Progress {
Expand Down Expand Up @@ -341,6 +345,8 @@ impl Route {
return Route::Deleted;
} else if path == "/watching/" {
return Route::Watching;
} else if path == "/watched/" {
return Route::Watched;
} else if path.starts_with("/cluster/") {
if path == "/cluster/downloading/" {
return Route::Cluster(ClusterRoute::Downloading);
Expand Down
12 changes: 12 additions & 0 deletions src/daemon/tracking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ impl Tracking {
_ => None,
}).collect()
}
// only for UI
pub fn get_watched(&self) -> BTreeMap<VPath, Option<ImageId>> {
let mut state = self.state();
state.poll_watched();
state.watched.iter()
.map(|(x, y)| match y {
&WatchedStatus::Complete(ref id) => {
(x.clone(), Some(id.clone()))
}
_ => (x.clone(), None),
}).collect()
}
pub fn get_connection_by_mask<P: Policy>(&self,
vpath: &VPath, id: &ImageId, mask: Mask,
failures: &Failures<SocketAddr, P>)
Expand Down

0 comments on commit 37f0a78

Please sign in to comment.