refactor(tvix/store/bin): move service.clone right before async move

Change-Id: I7a2b951d9c9251a053a0de40f31836bda03a922d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10408
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Florian Klink 2023-12-22 14:25:41 +02:00 committed by flokli
parent 39cddb95be
commit 93a228b9a4

View file

@ -260,11 +260,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tasks = paths
.into_iter()
.map(|path| {
let task: JoinHandle<io::Result<()>> = tokio::task::spawn({
let blob_service = blob_service.clone();
let directory_service = directory_service.clone();
let path_info_service = path_info_service.clone();
let task: JoinHandle<io::Result<()>> = tokio::task::spawn(async move {
async move {
// Ingest the path into blob and directory service.
let root_node = import::ingest_path(
blob_service.clone(),
@ -285,7 +286,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.to_str()
.expect("path must be valid unicode");
let output_path = store_path::build_nar_based_store_path(&nar_sha256, name);
let output_path =
store_path::build_nar_based_store_path(&nar_sha256, name);
// assemble a new root_node with a name that is derived from the nar hash.
let root_node =
@ -305,7 +307,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
reference_names: vec![],
deriver: None,
ca: Some(nar_info::Ca {
r#type: tvix_store::proto::nar_info::ca::Hash::NarSha256.into(),
r#type: tvix_store::proto::nar_info::ca::Hash::NarSha256
.into(),
digest: nar_sha256.to_vec().into(),
}),
}),
@ -327,6 +330,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
);
Ok(())
}
});
task
})