Desktop: downloads are written beside and put in place, not rewritten
On macOS (Apple silicon) Rodent IV build 2, downloaded over the 1.7 build, was killed at its first start: the kernel keeps the signature of an executable that once ran, and the file had been rewritten in place. The owner's Mac ran the same build fine from a fresh file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fa2be527c6
commit
8e79a888ef
2 changed files with 25 additions and 1 deletions
|
|
@ -4,6 +4,9 @@ All notable changes are listed here. Versions follow [Semantic Versioning](https
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- macOS: an engine downloaded over an older one (Rodent IV from 1.7 to 1.8) no longer
|
||||
fails «it does not start on this computer»: a download is written beside and put in
|
||||
place, never rewritten in place (Apple silicon kills an executable changed that way).
|
||||
- Desktop: a move can be taken back only in a blitz game against the computer; in rapid,
|
||||
classical and games without a clock «↶ Take back» (and Ctrl+Z) is gone.
|
||||
|
||||
|
|
|
|||
|
|
@ -228,13 +228,34 @@ fn run(report: &dyn Fn(Stage), cancel: &AtomicBool) -> Result<PathBuf, Failure>
|
|||
result
|
||||
}
|
||||
|
||||
/// Downloads `url` into `to`, checking the size and the SHA-256 on the way.
|
||||
/// Downloads `url` into `to`, checking the size and the SHA-256 on the way. The file is
|
||||
/// written beside and put in place once checked: a new file, never the old one rewritten
|
||||
/// (macOS on Apple silicon kills an executable rewritten in place after it once ran: it
|
||||
/// keeps the old signature for that file).
|
||||
pub fn fetch(
|
||||
url: &str,
|
||||
to: &Path,
|
||||
asset: &Asset,
|
||||
report: &dyn Fn(Stage),
|
||||
cancel: &AtomicBool,
|
||||
) -> Result<(), Failure> {
|
||||
let mut part = to.as_os_str().to_owned();
|
||||
part.push(".part");
|
||||
let part = PathBuf::from(part);
|
||||
let result = fetch_into(url, &part, asset, report, cancel)
|
||||
.and_then(|()| std::fs::rename(&part, to).map_err(disk));
|
||||
if result.is_err() {
|
||||
let _ = std::fs::remove_file(&part);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn fetch_into(
|
||||
url: &str,
|
||||
to: &Path,
|
||||
asset: &Asset,
|
||||
report: &dyn Fn(Stage),
|
||||
cancel: &AtomicBool,
|
||||
) -> Result<(), Failure> {
|
||||
let mut response = ureq::get(url).call().map_err(|e| match e {
|
||||
ureq::Error::StatusCode(code) => Failure::Server(code),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue