Skip to content

Commit

Permalink
extract materialize_copy_source_tasks function
Browse files Browse the repository at this point in the history
Reviewed By: IanChilds

Differential Revision: D68562486

fbshipit-source-id: 5b2f0e10b4ec572f4d774915d7b1cd5b3e986d68
  • Loading branch information
blackm00n authored and facebook-github-bot committed Jan 23, 2025
1 parent 9092259 commit e562e1f
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions app/buck2_execute_impl/src/materializers/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1905,21 +1905,10 @@ impl<T: IoHandler> DeferredMaterializerCommandProcessor<T> {
"materialize artifact"
);

// If the artifact copies from other artifacts, we must materialize them first
let method = entry_and_method.as_ref().map(|(_, m)| m.as_ref());
let deps_tasks = match method {
Some(ArtifactMaterializationMethod::LocalCopy(_, copied_artifacts)) => copied_artifacts
.iter()
.filter_map(|a| {
self.materialize_artifact_recurse(
MaterializeStack::Child(&stack, path),
a.src.as_ref(),
event_dispatcher.dupe(),
)
})
.collect::<Vec<_>>(),
_ => Vec::new(),
};
// Those are special because if the artifact copies from other artifacts, we must materialize them first
let materialize_copy_source_tasks =
self.materialize_copy_source_tasks(&stack, &event_dispatcher, path, method);

// The artifact might have symlinks pointing to other artifacts. We must
// materialize them as well, to avoid dangling symlinks.
Expand Down Expand Up @@ -1964,7 +1953,7 @@ impl<T: IoHandler> DeferredMaterializerCommandProcessor<T> {

// In case this is a local copy, we first need to materialize the
// artifacts we are copying from, before we can copy them.
for t in deps_tasks {
for t in materialize_copy_source_tasks {
t.await?;
}

Expand Down Expand Up @@ -2028,6 +2017,28 @@ impl<T: IoHandler> DeferredMaterializerCommandProcessor<T> {
Ok(Some(task))
}

fn materialize_copy_source_tasks(
&mut self,
stack: &MaterializeStack,
event_dispatcher: &EventDispatcher,
path: &ProjectRelativePath,
method: Option<&ArtifactMaterializationMethod>,
) -> Vec<MaterializingFuture> {
match method {
Some(ArtifactMaterializationMethod::LocalCopy(_, copied_artifacts)) => copied_artifacts
.iter()
.filter_map(|a| {
self.materialize_artifact_recurse(
MaterializeStack::Child(&stack, path),
a.src.as_ref(),
event_dispatcher.dupe(),
)
})
.collect::<Vec<_>>(),
_ => Vec::new(),
}
}

#[instrument(level = "debug", skip(self, result), fields(path = %artifact_path))]
fn materialization_finished(
&mut self,
Expand Down

0 comments on commit e562e1f

Please sign in to comment.