files: take into account that also closing a backup file can fail

Only when fclose() is called, does the data get flushed out to disk,
and maybe only then the system realizes that there is no space left on
the device, as Chris noted in: https://savannah.gnu.org/bugs/?24000.
master
Benno Schulenberg 2020-05-29 11:32:35 +02:00
parent 586d22109b
commit 512b0fd32d
1 changed files with 10 additions and 1 deletions

View File

@ -1701,7 +1701,16 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
* Failure is unimportant: saving the file apparently worked. */
IGNORE_CALL_RESULT(futimens(backup_fd, filetime));
fclose(backup_file);
if (fclose(backup_file) != 0) {
warn_and_briefly_pause(_("Cannot write backup"));
if (user_wants_to_proceed())
goto skip_backup;
statusline(HUSH, _("Cannot write backup %s: %s"),
backupname, strerror(errno));
free(backupname);
goto cleanup_and_exit;
}
free(backupname);
}