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
parent
586d22109b
commit
512b0fd32d
11
src/files.c
11
src/files.c
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue