fix: use temp file on same device with mcp file edit (#20477)

Otherwise you can get errors like "invalid cross-device link".
This commit is contained in:
Asher
2025-10-29 12:23:06 -08:00
committed by GitHub
parent c827a08c11
commit 643fe38b1e
+3 -1
View File
@@ -250,7 +250,9 @@ func (a *agent) editFile(ctx context.Context, path string, edits []workspacesdk.
transforms[i] = replace.String(edit.Search, edit.Replace)
}
tmpfile, err := afero.TempFile(a.filesystem, "", filepath.Base(path))
// Create an adjacent file to ensure it will be on the same device and can be
// moved atomically.
tmpfile, err := afero.TempFile(a.filesystem, filepath.Dir(path), filepath.Base(path))
if err != nil {
return http.StatusInternalServerError, err
}