Fix Redbean when file is read-only (#365)

This commit is contained in:
Paul Kulchenko 2022-03-14 17:13:28 -07:00 committed by GitHub
parent 22409b2b5e
commit 38112aeb20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View file

@ -6884,8 +6884,8 @@ static void RestoreApe(void) {
if (endswith(zpath, ".com.dbg")) return;
if ((a = GetAssetZip("/.ape", 5)) && (p = LoadAsset(a, &n))) {
close(zfd);
zfd = OpenExecutable();
write(zfd, p, n);
if ((zfd = OpenExecutable()) == -1 || write(zfd, p, n) == -1)
WARNF("(srvr) can't restore .ape");
free(p);
} else {
WARNF("(srvr) /.ape not found");