mirror of
https://codeberg.org/spire/depot-prefetch.git
synced 2026-06-03 10:04:09 +02:00
add date to output
This commit is contained in:
parent
a8d3b58551
commit
f0b52970ef
5 changed files with 78 additions and 14 deletions
54
Cargo.lock
generated
54
Cargo.lock
generated
|
|
@ -513,6 +513,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"steam-vent",
|
"steam-vent",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
|
@ -530,6 +531,16 @@ dependencies = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deranged"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
|
||||||
|
dependencies = [
|
||||||
|
"powerfmt",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.10.7"
|
version = "0.10.7"
|
||||||
|
|
@ -1319,6 +1330,12 @@ dependencies = [
|
||||||
"num-traits 0.2.19",
|
"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]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.46"
|
version = "0.1.46"
|
||||||
|
|
@ -1538,6 +1555,12 @@ dependencies = [
|
||||||
"zerovec",
|
"zerovec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "powerfmt"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.21"
|
version = "0.2.21"
|
||||||
|
|
@ -2301,6 +2324,37 @@ dependencies = [
|
||||||
"cfg-if",
|
"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]]
|
[[package]]
|
||||||
name = "tinystr"
|
name = "tinystr"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,5 @@ clap = { version = "4.5.40", features = ["derive"] }
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-subscriber = "0.3.19"
|
tracing-subscriber = "0.3.19"
|
||||||
itertools = "0.14.0"
|
itertools = "0.14.0"
|
||||||
|
time = { version = "0.3.41", features = ["serde", "formatting"] }
|
||||||
|
|
@ -31,6 +31,7 @@ instead.
|
||||||
"app_id": <app id>,
|
"app_id": <app id>,
|
||||||
"depot_id": <depot id>,
|
"depot_id": <depot id>,
|
||||||
"manifest": <latest manifest id for the depot>,
|
"manifest": <latest manifest id for the depot>,
|
||||||
|
"date": <update date in rfc3339>,
|
||||||
"hash": <nix hash of the manifest>
|
"hash": <nix hash of the manifest>
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
|
|
|
||||||
11
src/main.rs
11
src/main.rs
|
|
@ -1,10 +1,12 @@
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use crate::prefetch::{prefetch, PrefetchError};
|
use crate::prefetch::{prefetch, PrefetchError};
|
||||||
use crate::product_info::{ProductInfoError, ProductInfoFetcher};
|
use crate::product_info::{ProductInfoError, ProductInfoFetcher};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use main_error::MainResult;
|
use main_error::MainResult;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use time::OffsetDateTime;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, error, info};
|
||||||
|
|
||||||
|
|
@ -124,9 +126,12 @@ async fn get_manifests(
|
||||||
product_args: &ProductArgs,
|
product_args: &ProductArgs,
|
||||||
) -> Result<Vec<ManifestInput>, ProductInfoError> {
|
) -> Result<Vec<ManifestInput>, ProductInfoError> {
|
||||||
let depots = info_fetcher.fetch_depots(product_args.app_id).await?;
|
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
|
Ok(depots
|
||||||
|
.depots
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
.filter_map(|(id, depot)| Some((u32::from_str(&id).ok()?, depot)))
|
||||||
.filter(|(depot_id, _)| {
|
.filter(|(depot_id, _)| {
|
||||||
product_args.depot.is_empty() || product_args.depot.contains(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,
|
app_id: product_args.app_id,
|
||||||
depot_id,
|
depot_id,
|
||||||
manifest: manifest.gid,
|
manifest: manifest.gid,
|
||||||
|
date: OffsetDateTime::from_unix_timestamp(branch as i64).unwrap(),
|
||||||
})
|
})
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
@ -152,6 +158,7 @@ fn fetch_inputs(inputs: impl IntoIterator<Item = ManifestInput>, file_list: &[St
|
||||||
app_id: input.app_id,
|
app_id: input.app_id,
|
||||||
depot_id: input.depot_id,
|
depot_id: input.depot_id,
|
||||||
manifest: input.manifest,
|
manifest: input.manifest,
|
||||||
|
date: input.date,
|
||||||
hash,
|
hash,
|
||||||
file_list: file_list.into(),
|
file_list: file_list.into(),
|
||||||
})
|
})
|
||||||
|
|
@ -163,6 +170,8 @@ struct ManifestInput {
|
||||||
app_id: u32,
|
app_id: u32,
|
||||||
depot_id: u32,
|
depot_id: u32,
|
||||||
manifest: u64,
|
manifest: u64,
|
||||||
|
#[serde(with = "time::serde::rfc3339")]
|
||||||
|
date: OffsetDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
|
@ -170,6 +179,8 @@ struct ManifestOutput {
|
||||||
app_id: u32,
|
app_id: u32,
|
||||||
depot_id: u32,
|
depot_id: u32,
|
||||||
manifest: u64,
|
manifest: u64,
|
||||||
|
#[serde(with = "time::serde::rfc3339")]
|
||||||
|
date: OffsetDateTime,
|
||||||
hash: String,
|
hash: String,
|
||||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||||
file_list: Vec<String>,
|
file_list: Vec<String>,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use std::str::FromStr;
|
|
||||||
use std::string::FromUtf8Error;
|
use std::string::FromUtf8Error;
|
||||||
use steam_vent::proto::steammessages_clientserver_appinfo::{
|
use steam_vent::proto::steammessages_clientserver_appinfo::{
|
||||||
CMsgClientPICSProductInfoRequest, CMsgClientPICSProductInfoResponse,
|
CMsgClientPICSProductInfoRequest, CMsgClientPICSProductInfoResponse,
|
||||||
|
|
@ -26,7 +25,7 @@ impl ProductInfoFetcher {
|
||||||
pub async fn fetch_depots(
|
pub async fn fetch_depots(
|
||||||
&self,
|
&self,
|
||||||
app_id: u32,
|
app_id: u32,
|
||||||
) -> Result<BTreeMap<u32, Depot>, ProductInfoError> {
|
) -> Result<Depots, ProductInfoError> {
|
||||||
let msg = CMsgClientPICSProductInfoRequest {
|
let msg = CMsgClientPICSProductInfoRequest {
|
||||||
apps: vec![cmsg_client_picsproduct_info_request::AppInfo {
|
apps: vec![cmsg_client_picsproduct_info_request::AppInfo {
|
||||||
appid: Some(app_id),
|
appid: Some(app_id),
|
||||||
|
|
@ -51,11 +50,7 @@ impl ProductInfoFetcher {
|
||||||
|
|
||||||
Ok(vdf
|
Ok(vdf
|
||||||
.app_info
|
.app_info
|
||||||
.depots
|
.depots)
|
||||||
.depots
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|(depot_id, depot)| Some((u32::from_str(&depot_id).ok()?, depot)))
|
|
||||||
.collect())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,11 +69,11 @@ struct AppInfo {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Depots {
|
pub struct Depots {
|
||||||
overridescddb: bool,
|
overridescddb: bool,
|
||||||
branches: HashMap<String, Branch>,
|
pub branches: HashMap<String, Branch>,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
depots: BTreeMap<String, Depot>,
|
pub depots: BTreeMap<String, Depot>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
@ -106,9 +101,11 @@ pub struct Manifest {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Branch {
|
pub struct Branch {
|
||||||
timeupdated: u64,
|
#[serde(rename = "timeupdated")]
|
||||||
buildid: u64,
|
pub time_updated: u64,
|
||||||
|
#[serde(rename = "buildid")]
|
||||||
|
pub build_id: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue