]> git.wh0rd.org Git - nano.git/commitdiff
* files.c: Do not go on and attempt to write the main file if writing the...
authorChris Allegretta <chrisa@asty.org>
Sat, 9 Aug 2008 03:39:10 +0000 (03:39 +0000)
committerChris Allegretta <chrisa@asty.org>
Sat, 9 Aug 2008 03:39:10 +0000 (03:39 +0000)
          related to Savannah bug 24000.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4297 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index e4b5f4435fd730e7aec2aa200aa17f1a8c39c181..54ad1970b25b2bb8713b6af0a6cc38196364c446 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-08-08 Chris Allegretta <chrisa@asty.org>
+       * files.c: Do not go on and attempt to write the main file if writing the backup file failed,
+         related to Savannah bug 24000.
+
 2008-07-23 Chris Allegretta <chrisa@asty.org>
        * text.c: Reset openfile-> to OTHER after an undo or redo so we don't mistakenly
          mistakenly think this is an update when it's really an add.  Also
index a5607dd26641bd6377034c35677d5db6556fab47..11ac11dd971729649c466100950e072ee7255bd7 100644 (file)
@@ -1474,14 +1474,15 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
            free(backuptemp);
            backuptemp = get_next_filename(backupname, "~");
            if (*backuptemp == '\0') {
-               statusbar(_("Error writing %s: %s"), backupname,
+               statusbar(_("Error writing backup file %s: %s"), backupname,
                    _("Too many backup files?"));
                free(backuptemp);
                free(backupname);
-               /* If we can't write to the backup, go on, since only
-                * saving the original file is better than saving
-                * nothing. */
-               goto skip_backup;
+               /* If we can't write to the backup, DONT go on, since
+                  whatever caused the backup file to fail (e.g. disk
+                  full may well cause the real file write to fail, which
+                  means we could lose both the backup and the original! */
+               goto cleanup_and_exit;
            } else {
                free(backupname);
                backupname = backuptemp;
@@ -1498,14 +1499,16 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
 
        if (backup_file == NULL || chmod(backupname,
                openfile->current_stat->st_mode) == -1) {
-           statusbar(_("Error writing %s: %s"), backupname,
+           statusbar(_("Error writing backup file %s: %s"), backupname,
                strerror(errno));
            free(backupname);
            if (backup_file != NULL)
                fclose(backup_file);
-           /* If we can't write to the backup, go on, since only saving
-            * the original file is better than saving nothing. */
-           goto skip_backup;
+           /* If we can't write to the backup, DONT go on, since
+              whatever caused the backup file to fail (e.g. disk
+              full may well cause the real file write to fail, which
+              means we could lose both the backup and the original! */
+           goto cleanup_and_exit;
        }
 
 #ifdef DEBUG
@@ -1525,11 +1528,13 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
                        strerror(errno));
                beep();
            } else
-               statusbar(_("Error writing %s: %s"), backupname,
+               statusbar(_("Error writing backup file %s: %s"), backupname,
                        strerror(errno));
-           /* If we can't read from or write to the backup, go on,
-            * since only saving the original file is better than saving
-            * nothing. */
+           /* If we can't write to the backup, DONT go on, since
+              whatever caused the backup file to fail (e.g. disk
+              full may well cause the real file write to fail, which
+              means we could lose both the backup and the original! */
+           goto cleanup_and_exit;
        }
 
        free(backupname);