Fix request_counter check because fetch_add returns original value (#97)

This commit is contained in:
Nutomic 2024-03-08 15:36:44 +01:00 committed by GitHub
parent 9b31a7b44b
commit da28c9c890
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,7 +89,9 @@ async fn fetch_object_http_with_accept<T: Clone, Kind: DeserializeOwned>(
config.verify_url_valid(url).await?;
info!("Fetching remote object {}", url.to_string());
let counter = data.request_counter.fetch_add(1, Ordering::SeqCst);
let mut counter = data.request_counter.fetch_add(1, Ordering::SeqCst);
// fetch_add returns old value so we need to increment manually here
counter += 1;
if counter > config.http_fetch_limit {
return Err(Error::RequestLimit);
}