From: Max Khon Date: Thu, 26 Feb 2015 06:52:29 +0000 (+0600) Subject: Don't leave incompletely written output file if restore fails. X-Git-Tag: v1.5.0~10^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de37603751de80acb269e5e00f9b5f49cb1773ea;p=thirdparty%2Frrdtool-1.x.git Don't leave incompletely written output file if restore fails. --- diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 87c95f6a..24a4f379 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -1366,8 +1366,11 @@ int write_file( /* lets see if we had an error */ if (ferror(fh)) { - rrd_set_error("a file error occurred while creating '%s'", file_name); + rrd_set_error("a file error occurred while creating '%s': %s", file_name, + rrd_strerror(errno)); fclose(fh); + if (strcmp("-", file_name) != 0) + unlink(file_name); return (-1); }