add date to output

This commit is contained in:
Robin Appelman 2025-06-21 17:57:57 +02:00
commit f0b52970ef
5 changed files with 78 additions and 14 deletions

54
Cargo.lock generated
View file

@ -513,6 +513,7 @@ dependencies = [
"serde_json",
"steam-vent",
"thiserror 2.0.12",
"time",
"tokio",
"tracing",
"tracing-subscriber",
@ -530,6 +531,16 @@ dependencies = [
"zeroize",
]
[[package]]
name = "deranged"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
dependencies = [
"powerfmt",
"serde",
]
[[package]]
name = "digest"
version = "0.10.7"
@ -1319,6 +1330,12 @@ dependencies = [
"num-traits 0.2.19",
]
[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num-integer"
version = "0.1.46"
@ -1538,6 +1555,12 @@ dependencies = [
"zerovec",
]
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "ppv-lite86"
version = "0.2.21"
@ -2301,6 +2324,37 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "time"
version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
dependencies = [
"deranged",
"itoa",
"num-conv",
"powerfmt",
"serde",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
[[package]]
name = "time-macros"
version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
dependencies = [
"num-conv",
"time-core",
]
[[package]]
name = "tinystr"
version = "0.8.1"

View file

@ -16,4 +16,5 @@ clap = { version = "4.5.40", features = ["derive"] }
serde_json = "1.0.140"
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
itertools = "0.14.0"
itertools = "0.14.0"
time = { version = "0.3.41", features = ["serde", "formatting"] }

View file

@ -31,6 +31,7 @@ instead.
"app_id": <app id>,
"depot_id": <depot id>,
"manifest": <latest manifest id for the depot>,
"date": <update date in rfc3339>,
"hash": <nix hash of the manifest>
},
...

View file

@ -1,10 +1,12 @@
use std::process::Command;
use std::str::FromStr;
use std::time::Duration;
use crate::prefetch::{prefetch, PrefetchError};
use crate::product_info::{ProductInfoError, ProductInfoFetcher};
use clap::Parser;
use main_error::MainResult;
use serde::Serialize;
use time::OffsetDateTime;
use tokio::time::sleep;
use tracing::{debug, error, info};
@ -124,9 +126,12 @@ async fn get_manifests(
product_args: &ProductArgs,
) -> Result<Vec<ManifestInput>, ProductInfoError> {
let depots = info_fetcher.fetch_depots(product_args.app_id).await?;
let branch = depots.branches.get(&product_args.branch).map(|branch| branch.time_updated).unwrap_or_default();
Ok(depots
.depots
.into_iter()
.filter_map(|(id, depot)| Some((u32::from_str(&id).ok()?, depot)))
.filter(|(depot_id, _)| {
product_args.depot.is_empty() || product_args.depot.contains(depot_id)
})
@ -141,6 +146,7 @@ async fn get_manifests(
app_id: product_args.app_id,
depot_id,
manifest: manifest.gid,
date: OffsetDateTime::from_unix_timestamp(branch as i64).unwrap(),
})
.collect())
}
@ -152,6 +158,7 @@ fn fetch_inputs(inputs: impl IntoIterator<Item = ManifestInput>, file_list: &[St
app_id: input.app_id,
depot_id: input.depot_id,
manifest: input.manifest,
date: input.date,
hash,
file_list: file_list.into(),
})
@ -163,6 +170,8 @@ struct ManifestInput {
app_id: u32,
depot_id: u32,
manifest: u64,
#[serde(with = "time::serde::rfc3339")]
date: OffsetDateTime,
}
#[derive(Debug, Serialize)]
@ -170,6 +179,8 @@ struct ManifestOutput {
app_id: u32,
depot_id: u32,
manifest: u64,
#[serde(with = "time::serde::rfc3339")]
date: OffsetDateTime,
hash: String,
#[serde(skip_serializing_if = "Vec::is_empty")]
file_list: Vec<String>,

View file

@ -1,6 +1,5 @@
use serde::Deserialize;
use std::collections::{BTreeMap, HashMap};
use std::str::FromStr;
use std::string::FromUtf8Error;
use steam_vent::proto::steammessages_clientserver_appinfo::{
CMsgClientPICSProductInfoRequest, CMsgClientPICSProductInfoResponse,
@ -26,7 +25,7 @@ impl ProductInfoFetcher {
pub async fn fetch_depots(
&self,
app_id: u32,
) -> Result<BTreeMap<u32, Depot>, ProductInfoError> {
) -> Result<Depots, ProductInfoError> {
let msg = CMsgClientPICSProductInfoRequest {
apps: vec![cmsg_client_picsproduct_info_request::AppInfo {
appid: Some(app_id),
@ -51,11 +50,7 @@ impl ProductInfoFetcher {
Ok(vdf
.app_info
.depots
.depots
.into_iter()
.filter_map(|(depot_id, depot)| Some((u32::from_str(&depot_id).ok()?, depot)))
.collect())
.depots)
}
}
@ -74,11 +69,11 @@ struct AppInfo {
#[allow(dead_code)]
#[derive(Debug, Deserialize)]
struct Depots {
pub struct Depots {
overridescddb: bool,
branches: HashMap<String, Branch>,
pub branches: HashMap<String, Branch>,
#[serde(flatten)]
depots: BTreeMap<String, Depot>,
pub depots: BTreeMap<String, Depot>,
}
#[allow(dead_code)]
@ -106,9 +101,11 @@ pub struct Manifest {
#[allow(dead_code)]
#[derive(Debug, Deserialize)]
struct Branch {
timeupdated: u64,
buildid: u64,
pub struct Branch {
#[serde(rename = "timeupdated")]
pub time_updated: u64,
#[serde(rename = "buildid")]
pub build_id: u64,
}
#[derive(Debug, Error)]