Skip to content

Commit f2603fc

Browse files
committed
fix: Started solving some of the linter warnings
1 parent dd86c6d commit f2603fc

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/download.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use reqwest_retry::RetryTransientMiddleware;
88
use std::fs::File;
99
use std::io::BufRead;
1010
use std::io::BufReader;
11-
use std::path::PathBuf;
11+
use std::path::{Path, PathBuf};
1212
use std::process;
1313
use std::sync::Arc;
1414
use std::time::Duration;
@@ -40,7 +40,7 @@ fn new_client(max_retries: usize) -> Result<ClientWithMiddleware, DownloadError>
4040
pub async fn download_paths(
4141
snapshot: &String,
4242
data_type: &str,
43-
dst: &PathBuf,
43+
dst: &Path,
4444
) -> Result<(), DownloadError> {
4545
let paths = format!("{}crawl-data/{}/{}.paths.gz", BASE_URL, snapshot, data_type);
4646
println!("Downloading paths from: {}", paths);
@@ -55,7 +55,7 @@ pub async fn download_paths(
5555

5656
let request = client.get(url.as_str());
5757

58-
let mut dst = dst.clone();
58+
let mut dst = dst.to_path_buf();
5959

6060
dst.push(filename);
6161

@@ -65,7 +65,7 @@ pub async fn download_paths(
6565
let mut download = request.send().await?;
6666

6767
while let Some(chunk) = download.chunk().await? {
68-
outfile.write(&chunk).await?; // Write chunk to output file
68+
outfile.write_all(&chunk).await?; // Write chunk to output file
6969
}
7070

7171
outfile.flush().await?;
@@ -110,7 +110,7 @@ async fn download_task(
110110

111111
// Parse the filename from the given URL
112112
let filename = if numbered {
113-
&format!("{}{}", number.to_string(), ".txt.gz")
113+
&format!("{}{}", number, ".txt.gz")
114114
} else if files_only {
115115
url.path_segments()
116116
.and_then(|segments| segments.last())
@@ -166,7 +166,7 @@ async fn download_task(
166166
if progress {
167167
progress_bar.inc(chunk.len() as u64); // Increase ProgressBar by chunk size
168168
}
169-
outfile.write(&chunk).await?; // Write chunk to output file
169+
outfile.write_all(&chunk).await?; // Write chunk to output file
170170
}
171171

172172
if progress {
@@ -188,8 +188,8 @@ async fn download_task(
188188
}
189189

190190
pub async fn download(
191-
paths: &PathBuf,
192-
dst: &PathBuf,
191+
paths: &Path,
192+
dst: &Path,
193193
threads: usize,
194194
max_retries: usize,
195195
numbered: bool,
@@ -253,11 +253,8 @@ pub async fn download(
253253
let multibar = multibar.clone();
254254
let main_pb = main_pb.clone();
255255
let client = client.clone();
256-
let dst = dst.clone();
257-
let numbered = numbered.clone();
258-
let files_only = files_only.clone();
256+
let dst = dst.to_path_buf();
259257
let semaphore = semaphore.clone();
260-
let progress = progress.clone();
261258
set.spawn(async move {
262259
let _permit = semaphore.acquire().await;
263260
let res = download_task(

0 commit comments

Comments
 (0)