about summary refs log tree commit diff
path: root/tvix/store/src/bin/tvix-store.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-09-05T12·16+0300
committerclbot <clbot@tvl.fyi>2023-09-05T20·41+0000
commite41b5ae3f0cd0814367f1e2f4f256669c849fde7 (patch)
tree2b4f0c28293900577a3ae72e876d39923dbb210f /tvix/store/src/bin/tvix-store.rs
parent7bd3c42c747498dea657e0ed26ed5ec2a9eddda3 (diff)
refactor(tvix/store): infer more types r/6554
We don't need to explicitly describe the type of the task itself,
describing the return type of the async closure is sufficient.

Also, use io::Result<_> instead of Result<_, io::Error>.

Change-Id: I9ab3f990eb49929b0aea335b2bb07da392ab631f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9267
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/store/src/bin/tvix-store.rs')
-rw-r--r--tvix/store/src/bin/tvix-store.rs99
1 files changed, 48 insertions, 51 deletions
diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs
index f0cef0b98174..5b6c98e4ee45 100644
--- a/tvix/store/src/bin/tvix-store.rs
+++ b/tvix/store/src/bin/tvix-store.rs
@@ -191,59 +191,56 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
                     let directory_service = directory_service.clone();
                     let path_info_service = path_info_service.clone();
 
-                    let task: tokio::task::JoinHandle<Result<(), io::Error>> =
-                        tokio::task::spawn_blocking(move || {
-                            // Ingest the path into blob and directory service.
-                            let root_node = import::ingest_path(
-                                blob_service.clone(),
-                                directory_service.clone(),
-                                &path,
-                            )
-                            .expect("failed to ingest path");
-
-                            // Ask the PathInfoService for the NAR size and sha256
-                            let (nar_size, nar_sha256) =
-                                path_info_service.calculate_nar(&root_node)?;
-
-                            // TODO: make a path_to_name helper function?
-                            let name = path
-                                .file_name()
-                                .expect("path must not be ..")
-                                .to_str()
-                                .expect("path must be valid unicode");
-
-                            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 =
-                                root_node.rename(output_path.to_string().into_bytes().into());
-
-                            // assemble the [crate::proto::PathInfo] object.
-                            let path_info = PathInfo {
-                                node: Some(tvix_store::proto::Node {
-                                    node: Some(root_node),
-                                }),
-                                // There's no reference scanning on path contents ingested like this.
-                                references: vec![],
-                                narinfo: Some(NarInfo {
-                                    nar_size,
-                                    nar_sha256: nar_sha256.to_vec().into(),
-                                    signatures: vec![],
-                                    reference_names: vec![],
-                                }),
-                            };
-
-                            // put into [PathInfoService], and return the PathInfo that we get back
-                            // from there (it might contain additional signatures).
-                            let path_info = path_info_service.put(path_info)?;
-
-                            print_node(&path_info.node.unwrap().node.unwrap(), &path);
-                            Ok(())
-                        });
+                    let task = tokio::task::spawn_blocking(move || -> io::Result<()> {
+                        // Ingest the path into blob and directory service.
+                        let root_node = import::ingest_path(
+                            blob_service.clone(),
+                            directory_service.clone(),
+                            &path,
+                        )
+                        .expect("failed to ingest path");
+
+                        // Ask the PathInfoService for the NAR size and sha256
+                        let (nar_size, nar_sha256) = path_info_service.calculate_nar(&root_node)?;
+
+                        // TODO: make a path_to_name helper function?
+                        let name = path
+                            .file_name()
+                            .expect("path must not be ..")
+                            .to_str()
+                            .expect("path must be valid unicode");
+
+                        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 =
+                            root_node.rename(output_path.to_string().into_bytes().into());
+
+                        // assemble the [crate::proto::PathInfo] object.
+                        let path_info = PathInfo {
+                            node: Some(tvix_store::proto::Node {
+                                node: Some(root_node),
+                            }),
+                            // There's no reference scanning on path contents ingested like this.
+                            references: vec![],
+                            narinfo: Some(NarInfo {
+                                nar_size,
+                                nar_sha256: nar_sha256.to_vec().into(),
+                                signatures: vec![],
+                                reference_names: vec![],
+                            }),
+                        };
+
+                        // put into [PathInfoService], and return the PathInfo that we get back
+                        // from there (it might contain additional signatures).
+                        let path_info = path_info_service.put(path_info)?;
+
+                        print_node(&path_info.node.unwrap().node.unwrap(), &path);
+                        Ok(())
+                    });
                     task
                 })
-                .collect::<Vec<tokio::task::JoinHandle<Result<(), io::Error>>>>();
+                .collect::<Vec<_>>();
 
             try_join_all(tasks).await?;
         }