]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Don't leave incompletely written output file if restore fails.
authorMax Khon <fjoe@samodelkin.net>
Thu, 26 Feb 2015 06:52:29 +0000 (12:52 +0600)
committerMax Khon <fjoe@samodelkin.net>
Thu, 26 Feb 2015 06:52:29 +0000 (12:52 +0600)
src/rrd_restore.c

index 87c95f6af690ae46c58b7b54de7b0095b3dc9ea1..24a4f37997dd1a316d7926157b2e944bb3851288 100644 (file)
@@ -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);
     }