nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 512b0fd32d199ae45bc857fe66c3752f6dd13af8
parent 586d22109b8b6fc9909669fafb1a3c20b2aae6ab
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri, 29 May 2020 11:32:35 +0200

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.

Diffstat:
Msrc/files.c | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/files.c b/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); }