Skip to content

Commit

Permalink
Review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuhood committed Feb 14, 2019
1 parent d934b2b commit ca28196
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/rust/engine/fs/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ impl Snapshot {
future::ok(path_stats).to_boxed()
})
.map(move |path_stats_per_directory| {
let path_stats =
Iterator::flatten(path_stats_per_directory.into_iter().map(|v| v.into_iter())).collect();
let mut path_stats =
Iterator::flatten(path_stats_per_directory.into_iter().map(|v| v.into_iter()))
.collect::<Vec<_>>();
path_stats.sort_by(|l, r| l.path().cmp(&r.path()));
Snapshot { digest, path_stats }
})
.to_boxed()
Expand Down
14 changes: 8 additions & 6 deletions src/rust/engine/fs/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ impl Store {
/// Given the Digest for a Directory, recursively walk the Directory, calling the given function
/// with the path so far, and the new Directory.
///
/// The recursive walk will proceed concurrently, so if order matters, a caller should sort the
/// output after the call.
///
pub fn walk<
T: Send + 'static,
F: Fn(
Expand All @@ -598,13 +601,14 @@ impl Store {
&bazel_protos::remote_execution::Directory,
) -> BoxFuture<T, String>
+ Send
+ Sync
+ 'static,
>(
&self,
digest: Digest,
f: F,
) -> BoxFuture<Vec<T>, String> {
let f = Arc::new(Mutex::new(f));
let f = Arc::new(f);
let accumulator = Arc::new(Mutex::new(Vec::new()));
self
.walk_helper(digest, PathBuf::new(), f, accumulator.clone())
Expand All @@ -625,23 +629,21 @@ impl Store {
&bazel_protos::remote_execution::Directory,
) -> BoxFuture<T, String>
+ Send
+ Sync
+ 'static,
>(
&self,
digest: Digest,
path_so_far: PathBuf,
f: Arc<Mutex<F>>,
f: Arc<F>,
accumulator: Arc<Mutex<Vec<T>>>,
) -> BoxFuture<(), String> {
let store = self.clone();
self
.load_directory(digest)
.and_then(move |maybe_directory| match maybe_directory {
Some(directory) => {
let result_for_directory = {
let f = f.lock();
f(&store, &path_so_far, digest, &directory)
};
let result_for_directory = f(&store, &path_so_far, digest, &directory);
result_for_directory
.and_then(move |r| {
{
Expand Down

0 comments on commit ca28196

Please sign in to comment.