Fix rename handling

This commit is contained in:
mtkennerly 2024-04-21 08:37:44 -04:00
parent cb189ff6bf
commit b3a4153c7a
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
3 changed files with 14 additions and 10 deletions

View file

@ -5239,7 +5239,6 @@
* [Cool Dragon](https://www.pcgamingwiki.com/wiki/?curid=94003)
* [Cool Headed](https://www.pcgamingwiki.com/wiki/?curid=109028)
* [Cool Spot](https://www.pcgamingwiki.com/wiki/?curid=176670)
* [Cool World](https://www.pcgamingwiki.com/wiki/?curid=182987)
* [Coop Tank War](https://www.pcgamingwiki.com/wiki/?curid=121327)
* [Cop Academy](https://www.pcgamingwiki.com/wiki/?curid=130042)
* [Copa Petrobras de Marcas](https://www.pcgamingwiki.com/wiki/?curid=48262)

View file

@ -36511,8 +36511,6 @@ Cool Headed:
steam: 848660
Cool Spot:
pageId: 176670
Cool World:
pageId: 182987
Coop Tank War:
pageId: 121327
steam: 960010

View file

@ -299,23 +299,30 @@ impl WikiCache {
// (If they have a redirect, then the recent changes code takes care of it.)
let Some(new_title) = get_page_title(cached.page_id).await? else {
// Page no longer exists.
println!(":: refesh: page no longer exists");
println!(":: refresh: page no longer exists");
self.0.remove(title);
continue;
};
println!(
":: refresh: page {} called '{}' renamed to '{}'",
cached.page_id, title, &new_title
);
let mut data = self.0[title].clone();
data.renamed_from.push(title.clone());
self.0.insert(new_title.clone(), data);
self.0.remove(title);
if new_title.starts_with("File:") || new_title.starts_with("Company:") {
println!(":: refresh: page is no longer a game");
self.0.remove(title);
continue;
}
let mut latest = WikiCacheEntry::fetch_from_page(new_title.clone()).await?;
let mut cached = self.0[title].clone();
cached.renamed_from.push(title.clone());
latest.renamed_from = cached.renamed_from;
let mut latest = WikiCacheEntry::fetch_from_page(title.clone()).await?;
latest.renamed_from = cached.renamed_from.clone();
self.0.insert(new_title.clone(), latest);
self.0.remove(title);
}
Err(e) => {
return Err(e);