write ood flag correctly to db

This commit is contained in:
lukas-heiligenbrunner 2024-01-13 16:44:07 +01:00
parent 64ef138302
commit a7bfad31c1
2 changed files with 11 additions and 4 deletions

View File

@ -13,9 +13,7 @@ pub async fn build_pkgbuild(
) -> anyhow::Result<String> {
// update pacman cache
let mut child = tokio::process::Command::new("pacman")
.args([
"-Sy",
])
.args(["-Sy"])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?;

View File

@ -1,5 +1,5 @@
use crate::db::packages;
use crate::db::prelude::Packages;
use crate::db::prelude::{Packages, Versions};
use anyhow::anyhow;
use aur_rs::{Package, Request};
use sea_orm::ActiveValue::Set;
@ -45,8 +45,17 @@ async fn aur_check_versions(db: DatabaseConnection) -> anyhow::Result<()> {
}
Some(result) => {
let mut package: packages::ActiveModel = package.into();
// tdo remove unwraps and handle errors
let latest_version =
Versions::find_by_id(package.latest_version_id.clone().unwrap().unwrap())
.one(&db)
.await;
let latest_version = latest_version.map_or(None, |t| t);
package.latest_aur_version = Set(result.version.clone());
package.out_of_date = Set(latest_version
.map(|t1| if t1.version == result.version { 0 } else { 1 })
.unwrap_or(1));
let _ = package.update(&db).await;
}
}