env-read 14 -> 0 outside src/env_settings.rs (config/process_env.rs removed; typed text/number/path/mode accessors), glob-super-import 9 -> 0, allow-unused-imports 48 -> 0, 38 modules renamed by responsibility (worker_entry, serve_generation, file_download, pack_outputs, request_context, status_routes, ...). The hot-path code (admission, streaming, gRPC client) is untouched here. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
52 lines
1.0 KiB
Rust
52 lines
1.0 KiB
Rust
//! Manifest-pinned model acquisition. Finished files are never accepted by name alone.
|
|
|
|
use std::{
|
|
error::Error,
|
|
io,
|
|
path::{Component, Path, PathBuf},
|
|
time::Duration,
|
|
};
|
|
|
|
#[cfg(unix)]
|
|
use std::ffi::CString;
|
|
|
|
use reqwest::{
|
|
Client, RequestBuilder, StatusCode,
|
|
header::{ACCEPT_ENCODING, CONTENT_RANGE, RANGE},
|
|
};
|
|
use serde::Deserialize;
|
|
use sha2::{Digest, Sha256};
|
|
use tokio::{
|
|
fs::{self, File, OpenOptions},
|
|
io::{AsyncReadExt, AsyncWriteExt},
|
|
};
|
|
|
|
type Result<T> = std::result::Result<T, crate::BoxError>;
|
|
const FETCH_ATTEMPTS: usize = 4;
|
|
|
|
#[derive(Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct Manifest {
|
|
pub schema_version: u32,
|
|
pub files: Vec<ModelFile>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ModelFile {
|
|
pub name: String,
|
|
pub url: String,
|
|
pub size: u64,
|
|
pub sha256: String,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|
|
|
|
mod manifest_fetch;
|
|
#[allow(unused_imports)]
|
|
pub use manifest_fetch::*;
|
|
mod file_download;
|
|
#[allow(unused_imports)]
|
|
pub use file_download::*;
|