Skip to content

Commit 5195cdc

Browse files
GuillaumeGomezJoshua Nelson
authored and
Joshua Nelson
committed
Put back warning when rate limit has been reached on a specific updater but do not discard other updaters
1 parent 285837b commit 5195cdc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/repositories/updater.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::error::Result;
2-
use crate::repositories::{GitHub, GitLab};
2+
use crate::repositories::{GitHub, GitLab, RateLimitReached};
33
use crate::utils::MetadataPackage;
44
use crate::{db::Pool, Config};
55
use chrono::{DateTime, Utc};
@@ -128,7 +128,7 @@ impl RepositoryStatsUpdater {
128128

129129
pub fn update_all_crates(&self) -> Result<()> {
130130
let mut conn = self.pool.get()?;
131-
for updater in &self.updaters {
131+
'updaters: for updater in &self.updaters {
132132
info!("started updating `{}` repositories stats", updater.host());
133133

134134
let needs_update = conn
@@ -152,7 +152,19 @@ impl RepositoryStatsUpdater {
152152
// FIXME: The collect can be avoided if we use Itertools::chunks:
153153
// https://docs.rs/itertools/0.10.0/itertools/trait.Itertools.html#method.chunks.
154154
for chunk in needs_update.chunks(updater.chunk_size()) {
155-
let res = updater.fetch_repositories(chunk)?;
155+
let res = match updater.fetch_repositories(chunk) {
156+
Ok(r) => r,
157+
Err(err) => {
158+
if err.downcast_ref::<RateLimitReached>().is_some() {
159+
warn!(
160+
"rate limit reached, skipping the `{}` repository stats updater",
161+
updater.host()
162+
);
163+
continue 'updaters;
164+
}
165+
return Err(err);
166+
}
167+
};
156168
for node in res.missing {
157169
self.delete_repository(&mut conn, &node, updater.host())?;
158170
}

0 commit comments

Comments
 (0)