Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MOVE вызывает 500 ош ибку
On Tue, Dec 09, 2008 at 11:35:36PM +0300, Igor Sysoev wrote:
> On Tue, Dec 09, 2008 at 10:38:27PM +0300, Михаил Монашёв wrote:
>
> > Здравствуйте, Игорь.
> >
> > Патчик очень очень жду.
> >
> > Очень не хотелось бы заменять MOVE на GET и PUT.
>
> Патч, который делает промежуточные каталоги.
> Пока только для одиночных файлов.
Обновлённый патч.
--
Игорь Сысоев
http://sysoev.ru
Index: src/http/ngx_http_upstream.c
===================================================================
--- src/http/ngx_http_upstream.c (revision 1709)
+++ src/http/ngx_http_upstream.c (working copy)
@@ -2291,6 +2291,7 @@
ext.time = -1;
ext.create_path = 1;
ext.delete_file = 1;
+ ext.log_rename_error = 1;
ext.log = r->connection->log;
if (u->headers_in.last_modified) {
Index: src/http/modules/ngx_http_dav_module.c
===================================================================
--- src/http/modules/ngx_http_dav_module.c (revision 1709)
+++ src/http/modules/ngx_http_dav_module.c (working copy)
@@ -249,6 +249,7 @@
ext.time = -1;
ext.create_path = dlcf->create_full_put_path;
ext.delete_file = 1;
+ ext.log_rename_error = 1;
ext.log = r->connection->log;
if (r->headers_in.date) {
@@ -521,6 +522,7 @@
ngx_tree_ctx_t tree;
ngx_file_info_t fi;
ngx_table_elt_t *dest, *over;
+ ngx_ext_rename_file_t ext;
ngx_http_dav_copy_ctx_t copy;
ngx_http_dav_loc_conf_t *dlcf;
@@ -781,9 +783,29 @@
} else {
if (r->method == NGX_HTTP_MOVE) {
- if (ngx_rename_file(path.data, copy.path.data) != NGX_FILE_ERROR) {
+
+ ext.access = 0;
+ ext.time = -1;
+ ext.create_path = 1;
+ ext.delete_file = 0;
+ ext.log_rename_error = 0;
+ ext.log = r->connection->log;
+
+ if (ngx_ext_rename_file(&path, ©.path, &ext) == NGX_OK) {
return NGX_HTTP_NO_CONTENT;
}
+
+ if (ext.rename_error != NGX_EXDEV) {
+
+ if (ext.rename_error) {
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log,
+ ext.rename_error,
+ ngx_rename_file_n " \"%s\" to \"%s\" failed",
+ path.data, copy.path.data);
+ }
+
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
}
dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
Index: src/os/unix/ngx_errno.h
===================================================================
--- src/os/unix/ngx_errno.h (revision 1709)
+++ src/os/unix/ngx_errno.h (working copy)
@@ -23,6 +23,7 @@
#define NGX_EACCES EACCES
#define NGX_EBUSY EBUSY
#define NGX_EEXIST EEXIST
+#define NGX_EXDEV EXDEV
#define NGX_ENOTDIR ENOTDIR
#define NGX_EISDIR EISDIR
#define NGX_EINVAL EINVAL
Index: src/core/ngx_file.c
===================================================================
--- src/core/ngx_file.c (revision 1709)
+++ src/core/ngx_file.c (working copy)
@@ -487,11 +487,13 @@
#if !(NGX_WIN32)
- if (ngx_change_file_access(src->data, ext->access) == NGX_FILE_ERROR) {
- ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
- ngx_change_file_access_n " \"%s\" failed", src->data);
- err = 0;
- goto failed;
+ if (ext->access) {
+ if (ngx_change_file_access(src->data, ext->access) == NGX_FILE_ERROR) {
+ ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
+ ngx_change_file_access_n " \"%s\" failed",
src->data);
+ err = 0;
+ goto failed;
+ }
}
#endif
@@ -561,12 +563,14 @@
}
}
- if (err) {
+ if (err && ext->log_rename_error) {
ngx_log_error(NGX_LOG_CRIT, ext->log, err,
ngx_rename_file_n " \"%s\" to \"%s\" failed",
src->data, to->data);
}
+ ext->rename_error = err;
+
return NGX_ERROR;
}
Index: src/core/ngx_file.h
===================================================================
--- src/core/ngx_file.h (revision 1709)
+++ src/core/ngx_file.h (working copy)
@@ -62,9 +62,11 @@
ngx_uint_t access;
time_t time;
ngx_fd_t fd;
+ ngx_err_t rename_error;
unsigned create_path:1;
unsigned delete_file:1;
+ unsigned log_rename_error:1;
ngx_log_t *log;
} ngx_ext_rename_file_t;
|