forked from Hakase/nginx-build
Latest update - 7330
This commit is contained in:
+10
-7
@@ -796,10 +796,12 @@ ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf)
|
||||
{
|
||||
char *buf;
|
||||
off_t size;
|
||||
time_t time;
|
||||
size_t len;
|
||||
ssize_t n;
|
||||
ngx_fd_t fd, nfd;
|
||||
ngx_int_t rc;
|
||||
ngx_uint_t access;
|
||||
ngx_file_info_t fi;
|
||||
|
||||
rc = NGX_ERROR;
|
||||
@@ -814,8 +816,10 @@ ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (cf->size != -1) {
|
||||
if (cf->size != -1 && cf->access != 0 && cf->time != -1) {
|
||||
size = cf->size;
|
||||
access = cf->access;
|
||||
time = cf->time;
|
||||
|
||||
} else {
|
||||
if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
|
||||
@@ -825,7 +829,9 @@ ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
size = ngx_file_size(&fi);
|
||||
size = (cf->size != -1) ? cf->size : ngx_file_size(&fi);
|
||||
access = cf->access ? cf->access : ngx_file_access(&fi);
|
||||
time = (cf->time != -1) ? cf->time : ngx_file_mtime(&fi);
|
||||
}
|
||||
|
||||
len = cf->buf_size ? cf->buf_size : 65536;
|
||||
@@ -839,8 +845,7 @@ ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
nfd = ngx_open_file(to, NGX_FILE_WRONLY, NGX_FILE_CREATE_OR_OPEN,
|
||||
cf->access);
|
||||
nfd = ngx_open_file(to, NGX_FILE_WRONLY, NGX_FILE_TRUNCATE, access);
|
||||
|
||||
if (nfd == NGX_INVALID_FILE) {
|
||||
ngx_log_error(NGX_LOG_CRIT, cf->log, ngx_errno,
|
||||
@@ -887,13 +892,11 @@ ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf)
|
||||
size -= n;
|
||||
}
|
||||
|
||||
if (cf->time != -1) {
|
||||
if (ngx_set_file_time(to, nfd, cf->time) != NGX_OK) {
|
||||
if (ngx_set_file_time(to, nfd, time) != NGX_OK) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
|
||||
ngx_set_file_time_n " \"%s\" failed", to);
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
|
||||
rc = NGX_OK;
|
||||
|
||||
|
||||
@@ -845,7 +845,7 @@ overwrite_done:
|
||||
|
||||
cf.size = ngx_file_size(&fi);
|
||||
cf.buf_size = 0;
|
||||
cf.access = dlcf->access;
|
||||
cf.access = ngx_file_access(&fi);
|
||||
cf.time = ngx_file_mtime(&fi);
|
||||
cf.log = r->connection->log;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user