# HG changeset patch
# User Mindaugas Rasiukevicius <rmind@netbsd.org>
# Date 1436387157 -3600
#      Wed Jul 08 21:25:57 2015 +0100
# Node ID 9c978e51bf0e9bd6fc0fc04f4016a3c5701e9912
# Parent  dcae651b2a0cbd3de2f1fd5cf5b8c72627db94fd
ngx_ext_rename_file: remove the target file if ngx_copy_file() fails.

diff -r dcae651b2a0c -r 9c978e51bf0e src/core/ngx_file.c
--- a/src/core/ngx_file.c	Tue Jul 07 16:38:49 2015 +0300
+++ b/src/core/ngx_file.c	Wed Jul 08 21:25:57 2015 +0100
@@ -727,12 +727,11 @@ ngx_ext_rename_file(ngx_str_t *src, ngx_
             ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
                           ngx_rename_file_n " \"%s\" to \"%s\" failed",
                           name, to->data);
+        }
 
-            if (ngx_delete_file(name) == NGX_FILE_ERROR) {
-                ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
-                              ngx_delete_file_n " \"%s\" failed", name);
-
-            }
+        if (ngx_delete_file(name) == NGX_FILE_ERROR) {
+            ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
+                          ngx_delete_file_n " \"%s\" failed", name);
         }
 
         ngx_free(name);
