Sorry for my english but i'm having a little problem with a code of rust
the enigmatic code is this:
let mut continuar = true;
for node in html.find(Attr("class", "read_img").descendant(Name("a"))) {
// dbg!(node);
for imagen in node.find(Name("img")) {
// dbg!(imagen.attr("src").unwrap());
match imagen.attr("src") {
Some(url_imagen) => {
if continuar {
match bajar_imagen(
url_imagen,
directorio_capitulo,
&cliente,
)
.await
{
Ok(_) => {}
Err(e) => {
if e == "fichero_pequeño" {
imprimir_amarillo(
"Fichero muy pequeño menor o igual 195 bytes, borrar directorio",
);
borrar_directorio(&directorio_capitulo);
continuar = false;
} else {
imprimir_amarillo(
"Otro error al bajar imagen, borrar directorio",
);
println!("Error: {}", e);
borrar_directorio_y_panic(&directorio_capitulo);
}
}
}
}
}
None => {
imprimir_rojo(
"No se ha podido bajar la url dentro del src del html",
);
borrar_directorio_y_panic(&directorio_capitulo);
}
}
}
}
This funtion is async, but i was thinking that i only have one function a time
I have put a boolean name continuar, to go through the images while i don't get an especific error if i get an ERROR is a PANIC, tomorrow i will recode and do it, with .map and .collect but now i don't understand
i can pass you the playground of all of the code:
Perhaps it's the late night, i know that i have to redone the code more rustician way, i'm trying to get all the concepts
but my surprise is that i'm getting images, get an error, delete the directory but the program wants to write another file in the same directory. in a paralel work i will understand it, but i was thinking that i only have one threath of execution (async but only one)
This is from the terminal the messages i have seen and don't understand WHY
[src/main.rs:303] &url_imagen = "//l.mangatown.com/store/manga/29309/006.0/compressed/d000.jpg?token=def3fd3963efb203a11f3f5f32ac60544bfbc866&ttl=1585090800"
Fichero muy pequeño menor o igual 195 bytes, borrar directorio
Se ha borrado el directorio
[src/main.rs:303] &url_imagen = "//l.mangatown.com/store/manga/29309/006.0/compressed/d001.jpg?token=9a49a03549cdbf92d8c7006f226b1b8bc581ffd0&ttl=1585090800"
Error al crear fichero, borrar directorio
Error: No such file or directory (os error 2)
No he podido borrar directorio
Error: No such file or directory (os error 2)
i know that i get an error (i believe that i put the boolean continuar to false, because i want to stop in a good way, but the programs get an internal error of bajar_imagen the next one
i'm writing in a nfs systems.... ¿?¿? but with only one thread i theory don't have any problem.
Many thanks in advance now i'm getting at least seven hours of sleep and tomorrow i will try to understand this (perhaps it's a silly mistake)