preserve crate ordering from workspace

This commit is contained in:
Sam Rijs 2018-02-11 15:03:09 +11:00
parent e1c921066b
commit 9421c09a2c

View file

@ -3,7 +3,7 @@ use std::path::PathBuf;
use failure::Error; use failure::Error;
use futures::{Async, Future, Poll, Stream}; use futures::{Async, Future, Poll, Stream};
use futures::stream::FuturesUnordered; use futures::stream::FuturesOrdered;
use ::models::repo::RepoPath; use ::models::repo::RepoPath;
@ -15,7 +15,7 @@ pub struct CrawlManifestFuture {
repo_path: RepoPath, repo_path: RepoPath,
engine: Engine, engine: Engine,
crawler: ManifestCrawler, crawler: ManifestCrawler,
unordered: FuturesUnordered<Box<Future<Item=(PathBuf, String), Error=Error>>> futures: FuturesOrdered<Box<Future<Item=(PathBuf, String), Error=Error>>>
} }
impl CrawlManifestFuture { impl CrawlManifestFuture {
@ -24,11 +24,11 @@ impl CrawlManifestFuture {
.map(move |contents| (entry_point, contents))); .map(move |contents| (entry_point, contents)));
let engine = engine.clone(); let engine = engine.clone();
let crawler = ManifestCrawler::new(); let crawler = ManifestCrawler::new();
let mut unordered = FuturesUnordered::new(); let mut futures = FuturesOrdered::new();
unordered.push(future); futures.push(future);
CrawlManifestFuture { CrawlManifestFuture {
repo_path, engine, crawler, unordered repo_path, engine, crawler, futures
} }
} }
} }
@ -38,7 +38,7 @@ impl Future for CrawlManifestFuture {
type Error = Error; type Error = Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match try_ready!(self.unordered.poll()) { match try_ready!(self.futures.poll()) {
None => { None => {
let crawler = mem::replace(&mut self.crawler, ManifestCrawler::new()); let crawler = mem::replace(&mut self.crawler, ManifestCrawler::new());
Ok(Async::Ready(crawler.finalize())) Ok(Async::Ready(crawler.finalize()))
@ -48,7 +48,7 @@ impl Future for CrawlManifestFuture {
for path in output.paths_of_interest.into_iter() { for path in output.paths_of_interest.into_iter() {
let future: Box<Future<Item=_, Error=_>> = Box::new(self.engine.retrieve_manifest_at_path(&self.repo_path, &path) let future: Box<Future<Item=_, Error=_>> = Box::new(self.engine.retrieve_manifest_at_path(&self.repo_path, &path)
.map(move |contents| (path, contents))); .map(move |contents| (path, contents)));
self.unordered.push(future); self.futures.push(future);
} }
self.poll() self.poll()
} }