fixes
This commit is contained in:
parent
5167058b92
commit
89d5a91134
17
src/main.rs
17
src/main.rs
@ -166,8 +166,8 @@ impl Retriever {
|
||||
Err(error) => {
|
||||
self.trace.push(error);
|
||||
self.tries_left = self.tries_left.saturating_sub(1);
|
||||
if self.tries == 0 {
|
||||
bail!("Wasn't able to retrieve data in {} tries. Trace log:\n{:?}", self.tries, self.trace);
|
||||
if self.tries_left == 0 {
|
||||
bail!("Wasn't able to retrieve data in {} tries.", self.tries);
|
||||
} else {
|
||||
sleep(self.interval);
|
||||
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…")
|
||||
}
|
||||
|
||||
@ -245,24 +245,27 @@ fn main () {
|
||||
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 out = env::var("OUT_LOCATION").unwrap_or_else(|_| String::from("./data.json"));
|
||||
|
||||
let benchmark = Instant::now();
|
||||
let mut retriever = Retriever::new(cookie).with_tries(5).with_interval(Duration::from_secs(7));
|
||||
let run = retriever.run();
|
||||
|
||||
if let Ok(fetched) = run {
|
||||
match run {
|
||||
Ok(fetched) => {
|
||||
println!("Successfully fetched {} users in {} ms, writing out to {}…", fetched, benchmark.elapsed().as_millis(), out);
|
||||
// @TODO write
|
||||
} else {
|
||||
},
|
||||
Err(e) => {
|
||||
eprintln!("Wasn't able to retrieve data. Logs are below:");
|
||||
eprintln!("---");
|
||||
println!("{}", e);
|
||||
eprintln!("---");
|
||||
for line in retriever.trace {
|
||||
eprintln!("{}", line);
|
||||
}
|
||||
eprintln!("---");
|
||||
eprintln!("Exiting…")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user