Reject overwrite when share metadata missing

This commit is contained in:
Charles Cunningham
2026-02-15 20:36:15 -08:00
parent 726369eaa6
commit 68730de96d
2 changed files with 4 additions and 13 deletions

View File

@@ -146,18 +146,9 @@ pub async fn upload_rollout_with_owner(
upload_meta(&store, &meta_key, &updated).await?;
}
(true, None) => {
// Recover from a previous metadata upload failure by restoring metadata
// and overwriting the rollout blob.
let meta = SessionShareMeta {
owner: owner.to_string(),
created_at: now,
updated_at: now,
};
upload_meta(&store, &meta_key, &meta).await?;
store
.put_object(&key, data, "application/x-ndjson")
.await
.with_context(|| format!("failed to upload rollout for id {session_id}"))?;
return Err(anyhow::anyhow!(
"remote session already exists but has no metadata; refusing to overwrite"
));
}
(false, Some(meta)) => {
if meta.owner != owner {

View File

@@ -126,7 +126,7 @@ fn cargo_target_dir() -> Result<PathBuf, CargoBinError> {
fn absolutize_from_buck_or_cwd(path: PathBuf) -> Result<PathBuf, CargoBinError> {
path.absolutize()
.map(|abs| abs.into_owned())
.map(std::borrow::Cow::into_owned)
.map_err(|source| CargoBinError::CurrentDir { source })
}