i5-add-tests (part 4) #10
1 changed files with 9 additions and 6 deletions
|
@ -5,12 +5,15 @@ use std::io::{BufRead, BufReader};
|
||||||
use super::Link;
|
use super::Link;
|
||||||
|
|
||||||
pub fn find(link: &Link, file_name: &str, e: &FileEnv) -> Result<bool> {
|
pub fn find(link: &Link, file_name: &str, e: &FileEnv) -> Result<bool> {
|
||||||
if let Ok(file) = (e.open)(file_name) {
|
println!("Opening file: {file_name}");
|
||||||
let reader = BufReader::new(file);
|
let file = (e.open)(file_name)?;
|
||||||
for line in reader.lines() {
|
println!("Opened file: {file_name}");
|
||||||
if line? == link.href {
|
let reader = BufReader::new(file);
|
||||||
return Ok(true); // is already downloaded
|
for line in reader.lines() {
|
||||||
}
|
let line = line?;
|
||||||
|
if line == link.href {
|
||||||
|
println!("history: {}", line);
|
||||||
|
return Ok(true); // is already downloaded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(false) // is not already downloaded
|
Ok(false) // is not already downloaded
|
||||||
|
|
Loading…
Add table
Reference in a new issue