feat: readable download names and PUT /capture-profiles/:id
- downloads are named <orbit>_<time>_<engine>_<id8>.<ext> (schedule zone or UTC), orbit names are reduced to [a-z0-9_-], and the header carries filename and filename* - operators can change a profile's schedule and retention (absent = keep, null = clear), validated like registration, audited, and a changed schedule never replays slots that already passed Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -99,6 +99,35 @@ async fn download(
|
||||
.await
|
||||
.map_err(internal)?;
|
||||
let plan = exports::plan(&snapshot.manifest.restore_hints, &head);
|
||||
// The profile's schedule zone makes the time in the name match the one people see in their schedule.
|
||||
let application = snapshot
|
||||
.manifest
|
||||
.restore_hints
|
||||
.get("application_id")
|
||||
.and_then(|v| v.as_str())
|
||||
.and_then(|v| Uuid::parse_str(v).ok());
|
||||
let zone = application.and_then(|application| {
|
||||
state
|
||||
.db
|
||||
.capture_profiles()
|
||||
.ok()?
|
||||
.into_iter()
|
||||
.find(|p| p.application_id == application)?
|
||||
.schedule
|
||||
.map(|s| s.timezone)
|
||||
});
|
||||
let file_name = exports::download_name(
|
||||
&snapshot.manifest.orbit_name,
|
||||
snapshot.taken_at,
|
||||
zone.as_deref(),
|
||||
snapshot
|
||||
.manifest
|
||||
.restore_hints
|
||||
.get("engine")
|
||||
.and_then(|v| v.as_str()),
|
||||
id,
|
||||
plan.extension,
|
||||
);
|
||||
audit(AuditAction::ExportReady, AuditOutcome::Succeeded)?;
|
||||
|
||||
let reader = tokio::io::BufReader::with_capacity(CHUNK, file);
|
||||
@@ -124,8 +153,7 @@ async fn download(
|
||||
);
|
||||
headers.insert(
|
||||
header::CONTENT_DISPOSITION,
|
||||
HeaderValue::from_str(&format!("attachment; filename=\"{id}.{}\"", plan.extension))
|
||||
.map_err(internal)?,
|
||||
HeaderValue::from_str(&exports::content_disposition(&file_name)).map_err(internal)?,
|
||||
);
|
||||
headers.insert(header::CACHE_CONTROL, HeaderValue::from_static("no-store"));
|
||||
headers.insert(
|
||||
|
||||
Reference in New Issue
Block a user