Skip to content

Commit

Permalink
refactor: move functions out of vanilla.rs (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
SiongSng authored Sep 2, 2023
2 parents 1db7578 + 48308de commit c76e402
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 151 deletions.
5 changes: 3 additions & 2 deletions app/native/src/api/download.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::VecDeque,
path::PathBuf,
path::{Path, PathBuf},
sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Arc,
Expand Down Expand Up @@ -73,8 +73,9 @@ pub fn extract_filename(url: &str) -> Result<String> {
Ok(filename.to_owned())
}

pub async fn validate_sha1(file_path: &PathBuf, sha1: &str) -> Result<()> {
pub async fn validate_sha1(file_path: impl AsRef<Path> + Send + Sync, sha1: &str) -> Result<()> {
use sha1::{Digest, Sha1};
let file_path = file_path.as_ref();
let file = File::open(file_path).await?;
let mut buffer = Vec::new();
let mut reader = BufReader::new(file);
Expand Down
Loading

0 comments on commit c76e402

Please sign in to comment.