commit 2623f39c7b2d2f3e0e2fe8cba1628c778a7d87b9
parent da713220004c32aa3fbd6b31c5140a6028ec7595
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 17 Jul 2020 16:29:10 +0200
backup: when rereading the original file fails, ask the user what to do
Rereading is unlikely to fail, but *if* it fails, maybe there is a
serious problem and the user wants to try and fix it before saving
the buffer and thus overwriting the original file.
Diffstat:
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -1655,23 +1655,19 @@ bool make_backup_of(char *realname)
original = fopen(realname, "rb");
- /* If we can't read from the original file, go on, since saving
- * only the current buffer is better than saving nothing. */
if (original == NULL) {
- statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno));
+ warn_and_briefly_pause(_("Cannot read original file"));
fclose(backup_file);
- free(backupname);
- return TRUE;
+ goto failure;
}
/* Copy the existing file to the backup. */
verdict = copy_file(original, backup_file, FALSE);
if (verdict < 0) {
- statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno));
+ warn_and_briefly_pause(_("Cannot read original file"));
fclose(backup_file);
- free(backupname);
- return FALSE;
+ goto failure;
} else if (verdict > 0) {
fclose(backup_file);
goto problem;
@@ -1714,6 +1710,7 @@ bool make_backup_of(char *realname)
}
warn_and_briefly_pause(_("Cannot make backup"));
+ failure:
warn_and_briefly_pause(strerror(errno));
currmenu = MMOST;