allow specifying access key for backing up private demos

This commit is contained in:
Robin Appelman 2026-05-14 19:11:40 +02:00
commit a1b3b598e6
6 changed files with 50 additions and 15 deletions

View file

@ -1,5 +1,5 @@
use crate::store::Store;
use crate::Error;
use crate::store::Store;
use demostf_client::{ApiClient, Demo, ListOrder, ListParams};
use std::time::Duration;
use tokio::time::timeout;
@ -11,11 +11,13 @@ pub struct Backup {
}
impl Backup {
pub fn new(store: Store) -> Self {
Backup {
store,
client: ApiClient::new(),
pub fn new(store: Store, access_key: Option<String>) -> Self {
let mut client = ApiClient::new();
if let Some(access_key) = access_key {
info!("using access key");
client.set_access_key(access_key);
}
Backup { store, client }
}
#[instrument(skip_all, fields(demo.id = demo.id, demo.name = name))]

View file

@ -29,7 +29,13 @@ async fn main() -> Result<(), MainError> {
let mut args: HashMap<_, _> = dotenvy::vars().collect();
let store = Store::new(args.get("STORAGE_ROOT").expect("no STORAGE_ROOT set"));
let state_path = PathBuf::from(args.remove("STATE_FILE").expect("no STATE_FILE set"));
let backup = Backup::new(store);
let key_file = args.remove("ACCESS_KEY_FILE");
let access_key = key_file
.as_deref()
.map(secretfile::load)
.transpose()?
.filter(|key| !key.is_empty());
let backup = Backup::new(store, access_key);
let last_page = if state_path.is_file() {
max(