diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-04-23 11:15:16 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-04-23 11:15:16 +0300 |
commit | 35f3c2a309b7a39a079dc8223d3cc8da3f6704f7 (patch) | |
tree | a1ed71ba0fed7d99fe0c728c43aec24554957da0 | |
parent | 7ea9c6459d621a96fa496a2fe2ae4ecc941a33ce (diff) | |
download | summain-rs-35f3c2a309b7a39a079dc8223d3cc8da3f6704f7.tar.gz |
spawn task just for hashing
-rw-r--r-- | src/lib.rs | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -63,7 +63,8 @@ impl ManifestEntry { pub async fn new(path: &Path) -> std::io::Result<Self> { let m = symlink_metadata(path)?; let hash = if m.is_file() { - Some(file_checksum(path)?) + let path = path.to_path_buf(); + Some(tokio::task::spawn_blocking(move || file_checksum(path)).await??) } else { None }; @@ -85,7 +86,7 @@ impl ManifestEntry { } } -fn file_checksum(path: &Path) -> std::io::Result<String> { +fn file_checksum(path: PathBuf) -> std::io::Result<String> { let mut hasher = Sha256::new(); let file = File::open(path)?; |