Allow bulk updates with a limit and starting point

This commit is contained in:
mtkennerly 2023-12-18 00:28:16 +08:00
parent 06b2c877f0
commit e5a5cd4739
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
3 changed files with 49 additions and 11 deletions

View file

@ -12,12 +12,20 @@ impl ResourceFile for SteamCache {
}
impl SteamCache {
pub fn refresh(&mut self, outdated_only: bool, app_ids: Option<Vec<u32>>) -> Result<(), Error> {
pub fn refresh(
&mut self,
outdated_only: bool,
app_ids: Option<Vec<u32>>,
limit: Option<usize>,
from: Option<u32>,
) -> Result<(), Error> {
let mut i = 0;
let app_ids: Vec<_> = app_ids.unwrap_or_else(|| {
self.0
.iter()
.filter(|(_, v)| !outdated_only || v.state == State::Outdated)
.skip_while(|(k, _)| from.is_some_and(|from| &from != *k))
.take(limit.unwrap_or(usize::MAX))
.map(|(k, _)| *k)
.collect()
});