Add commit_id option to ServeWebArgs for specific client version (#255494)

* Add commit_id option to ServeWebArgs for specific client version

* Don't start serve-web update checker if given commit-id
This commit is contained in:
Justin Wang
2025-07-14 02:12:36 -04:00
committed by GitHub
parent cd20192782
commit b4d1fec915
2 changed files with 23 additions and 2 deletions

View File

@@ -216,6 +216,9 @@ pub struct ServeWebArgs {
/// Specifies the directory that server data is kept in.
#[clap(long)]
pub server_data_dir: Option<String>,
/// Use a specific commit SHA for the client.
#[clap(long)]
pub commit_id: Option<String>,
}
#[derive(Args, Debug, Clone)]

View File

@@ -88,8 +88,10 @@ pub async fn serve_web(ctx: CommandContext, mut args: ServeWebArgs) -> Result<i3
let cm: Arc<ConnectionManager> = ConnectionManager::new(&ctx, platform, args.clone());
let update_check_interval = 3600;
cm.clone()
.start_update_checker(Duration::from_secs(update_check_interval));
if args.commit_id.is_none() {
cm.clone()
.start_update_checker(Duration::from_secs(update_check_interval));
}
let key = get_server_key_half(&ctx.paths);
let make_svc = move || {
@@ -629,6 +631,22 @@ impl ConnectionManager {
Quality::try_from(q).map_err(|_| CodeError::UpdatesNotConfigured("unknown quality"))
})?;
if let Some(commit) = &self.args.commit_id {
let release = Release {
name: commit.to_string(),
commit: commit.to_string(),
platform: self.platform,
target: target_kind,
quality,
};
debug!(
self.log,
"using provided commit instead of latest release: {}", release
);
*latest = Some((now, release.clone()));
return Ok(release);
}
let release = self
.update_service
.get_latest_commit(self.platform, target_kind, quality)