mirror of
https://codeberg.org/demostf/backup.git
synced 2026-06-03 09:54:18 +02:00
allow specifying access key for backing up private demos
This commit is contained in:
parent
24f9594223
commit
a1b3b598e6
6 changed files with 50 additions and 15 deletions
|
|
@ -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))]
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue