fix: truncate auth.json file before rewriting it

This commit is contained in:
Michael Bolin
2025-06-05 22:00:15 -07:00
parent 515b6331bd
commit fa6ba8f2d9

View File

@@ -75,7 +75,7 @@ pub async fn try_read_openai_api_key(codex_home: &Path) -> std::io::Result<Strin
auth_dot_json.last_refresh = Utc::now();
let mut options = OpenOptions::new();
options.write(true).create(true);
options.truncate(true).write(true).create(true);
#[cfg(unix)]
{
options.mode(0o600);