tweaks: don't leave an orphaned temporary file behind when writing fails
Этот коммит содержится в:
родитель
803ea0d7a0
Коммит
3def429290
10
src/text.c
10
src/text.c
@ -2528,6 +2528,7 @@ void do_spell(void)
|
|||||||
|
|
||||||
if (!okay) {
|
if (!okay) {
|
||||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
|
unlink(temp_name);
|
||||||
free(temp_name);
|
free(temp_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2924,13 +2925,10 @@ void do_formatter(void)
|
|||||||
if (temp_name != NULL)
|
if (temp_name != NULL)
|
||||||
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
|
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
|
||||||
|
|
||||||
if (!okay) {
|
if (!okay)
|
||||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
free(temp_name);
|
else
|
||||||
return;
|
treat(temp_name, openfile->syntax->formatter, FALSE);
|
||||||
}
|
|
||||||
|
|
||||||
treat(temp_name, openfile->syntax->formatter, FALSE);
|
|
||||||
|
|
||||||
unlink(temp_name);
|
unlink(temp_name);
|
||||||
free(temp_name);
|
free(temp_name);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user