Fix trying to load hashes before loop finished.

This commit is contained in:
Syfaro 2020-01-14 02:19:42 -06:00
parent 5dc771421c
commit 880c5f385e

View File

@ -86,20 +86,17 @@ async fn main() {
.expect("Unable to build http client");
let client = std::sync::Arc::new(client);
let mut needed_posts = load_next_posts(pool.clone()).await;
loop {
println!("running loop");
let needed_posts = load_next_posts(pool.clone()).await;
if needed_posts.is_empty() {
println!("no posts, waiting a minute");
tokio::time::delay_for(std::time::Duration::from_secs(60)).await;
continue;
}
let db = pool.clone();
let posts_fut = tokio::spawn(async move { load_next_posts(db).await });
for chunk in needed_posts.chunks(8) {
let futs = chunk.iter().map(|post| {
let db = pool.clone();
@ -136,7 +133,5 @@ async fn main() {
futures::future::join_all(futs).await;
}
needed_posts = posts_fut.await.unwrap();
}
}