aKode update: il ripristino del binario non sovrascrive mai il file in uso
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -497,7 +497,12 @@ fn restore_binary(backup: &Path, exe: &Path) {
|
|||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
let _ = std::fs::rename(backup, exe);
|
let _ = std::fs::rename(backup, exe);
|
||||||
} else {
|
} else {
|
||||||
let _ = std::fs::copy(backup, exe);
|
// Copy to a fresh file and rename: overwriting the binary in place would corrupt a
|
||||||
|
// running executable (and invalidate its code signature on macOS).
|
||||||
|
let restored = exe.with_file_name(format!(".akode.restore-{}", std::process::id()));
|
||||||
|
if std::fs::copy(backup, &restored).is_ok() && std::fs::rename(&restored, exe).is_err() {
|
||||||
|
let _ = std::fs::remove_file(&restored);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user