fixes
This commit is contained in:
parent
5167058b92
commit
89d5a91134
33
src/main.rs
33
src/main.rs
@ -166,8 +166,8 @@ impl Retriever {
|
|||||||
Err(error) => {
|
Err(error) => {
|
||||||
self.trace.push(error);
|
self.trace.push(error);
|
||||||
self.tries_left = self.tries_left.saturating_sub(1);
|
self.tries_left = self.tries_left.saturating_sub(1);
|
||||||
if self.tries == 0 {
|
if self.tries_left == 0 {
|
||||||
bail!("Wasn't able to retrieve data in {} tries. Trace log:\n{:?}", self.tries, self.trace);
|
bail!("Wasn't able to retrieve data in {} tries.", self.tries);
|
||||||
} else {
|
} else {
|
||||||
sleep(self.interval);
|
sleep(self.interval);
|
||||||
return self.run();
|
return self.run();
|
||||||
@ -209,7 +209,7 @@ impl Retriever {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if members.len() as u32 != first_page.total {
|
if members.len() as u32 != expected {
|
||||||
bail!("User count changed during the retrieving process. Bailing…")
|
bail!("User count changed during the retrieving process. Bailing…")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,24 +245,27 @@ fn main () {
|
|||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
let cookie = read_cookie(cookie_filename).expect(&format!("Directory with executable should contain `{cookie_filename}` file containing a valid cookie for accessing Tilda control panel"));
|
let cookie = read_cookie(cookie_filename).expect(&format!("Directory with executable should contain `{cookie_filename}` file containing a valid cookie for accessing Tilda control panel"));
|
||||||
|
|
||||||
|
|
||||||
let out = env::var("OUT_LOCATION").unwrap_or_else(|_| String::from("./data.json"));
|
let out = env::var("OUT_LOCATION").unwrap_or_else(|_| String::from("./data.json"));
|
||||||
|
|
||||||
let benchmark = Instant::now();
|
let benchmark = Instant::now();
|
||||||
let mut retriever = Retriever::new(cookie).with_tries(5).with_interval(Duration::from_secs(7));
|
let mut retriever = Retriever::new(cookie).with_tries(5).with_interval(Duration::from_secs(7));
|
||||||
let run = retriever.run();
|
let run = retriever.run();
|
||||||
|
|
||||||
if let Ok(fetched) = run {
|
match run {
|
||||||
println!("Successfully fetched {} users in {} ms, writing out to {}…", fetched, benchmark.elapsed().as_millis(), out);
|
Ok(fetched) => {
|
||||||
// @TODO write
|
println!("Successfully fetched {} users in {} ms, writing out to {}…", fetched, benchmark.elapsed().as_millis(), out);
|
||||||
} else {
|
// @TODO write
|
||||||
eprintln!("Wasn't able to retrieve data. Logs are below:");
|
},
|
||||||
eprintln!("---");
|
Err(e) => {
|
||||||
for line in retriever.trace {
|
eprintln!("Wasn't able to retrieve data. Logs are below:");
|
||||||
eprintln!("{}", line);
|
eprintln!("---");
|
||||||
|
println!("{}", e);
|
||||||
|
eprintln!("---");
|
||||||
|
for line in retriever.trace {
|
||||||
|
eprintln!("{}", line);
|
||||||
|
}
|
||||||
|
eprintln!("---");
|
||||||
|
eprintln!("Exiting…")
|
||||||
}
|
}
|
||||||
eprintln!("---");
|
|
||||||
eprintln!("Exiting…")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user