write ood flag correctly to db
This commit is contained in:
parent
64ef138302
commit
a7bfad31c1
@ -13,9 +13,7 @@ pub async fn build_pkgbuild(
|
|||||||
) -> anyhow::Result<String> {
|
) -> anyhow::Result<String> {
|
||||||
// update pacman cache
|
// update pacman cache
|
||||||
let mut child = tokio::process::Command::new("pacman")
|
let mut child = tokio::process::Command::new("pacman")
|
||||||
.args([
|
.args(["-Sy"])
|
||||||
"-Sy",
|
|
||||||
])
|
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.spawn()?;
|
.spawn()?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::db::packages;
|
use crate::db::packages;
|
||||||
use crate::db::prelude::Packages;
|
use crate::db::prelude::{Packages, Versions};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use aur_rs::{Package, Request};
|
use aur_rs::{Package, Request};
|
||||||
use sea_orm::ActiveValue::Set;
|
use sea_orm::ActiveValue::Set;
|
||||||
@ -45,8 +45,17 @@ async fn aur_check_versions(db: DatabaseConnection) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
Some(result) => {
|
Some(result) => {
|
||||||
let mut package: packages::ActiveModel = package.into();
|
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.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;
|
let _ = package.update(&db).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user