Avoid false shell snapshot cleanup warnings (#18441)

## Why
Fresh app-server thread startup can create a shell snapshot through a
temp file and then promote it to the final snapshot path. The previous
implementation briefly wrapped the temp path in `ShellSnapshot`, so
after a successful rename its `Drop` attempted to delete the old temp
path and could log a false `ENOENT` warning.

Fixes #17549.

## What changed
- Validate the temp snapshot path directly before promotion.
- Rename the temp path directly to the final snapshot path.
- Keep explicit cleanup of the temp path on validation or finalization
failures.
This commit is contained in:
Eric Traut
2026-04-20 07:15:05 -07:00
committed by GitHub
Unverified
parent 904c751a40
commit fa0e2ba87c
+4 -9
View File
@@ -151,20 +151,15 @@ impl ShellSnapshot {
temp_path.display()
);
let temp_snapshot = Self {
path: temp_path.clone(),
cwd: session_cwd.clone(),
};
if let Err(err) = validate_snapshot(shell, &temp_snapshot.path, session_cwd).await {
if let Err(err) = validate_snapshot(shell, &temp_path, session_cwd).await {
tracing::error!("Shell snapshot validation failed: {err:?}");
remove_snapshot_file(&temp_snapshot.path).await;
remove_snapshot_file(&temp_path).await;
return Err("validation_failed");
}
if let Err(err) = fs::rename(&temp_snapshot.path, &path).await {
if let Err(err) = fs::rename(&temp_path, &path).await {
tracing::warn!("Failed to finalize shell snapshot: {err:?}");
remove_snapshot_file(&temp_snapshot.path).await;
remove_snapshot_file(&temp_path).await;
return Err("write_failed");
}