diff --git a/backend/src/pkgbuild/build.rs b/backend/src/pkgbuild/build.rs index 5186df7..0828ccc 100644 --- a/backend/src/pkgbuild/build.rs +++ b/backend/src/pkgbuild/build.rs @@ -13,9 +13,7 @@ pub async fn build_pkgbuild( ) -> anyhow::Result { // update pacman cache let mut child = tokio::process::Command::new("pacman") - .args([ - "-Sy", - ]) + .args(["-Sy"]) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn()?; diff --git a/backend/src/scheduler/aur_version_update.rs b/backend/src/scheduler/aur_version_update.rs index 0fa445f..b39d898 100644 --- a/backend/src/scheduler/aur_version_update.rs +++ b/backend/src/scheduler/aur_version_update.rs @@ -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; } }