Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Nginx upload module, state folder patch
Обкатываю этот модуль, наткнулся на небольшую проблему, обсуждение
которой есть по ссылке ниже.
https://github.com/vkholodkov/nginx-upload-module/issues/11
сделал небольшой патч, которым хотел бы поделиться и услышать критику
поэтому поводу.
diff -Naur nginx_upload_module-2.2.0/ngx_http_upload_module.c
nginx_upload_module-2.2.0.new/ngx_http_upload_module.c
--- nginx_upload_module-2.2.0/ngx_http_upload_module.c 2010-09-27
11:54:15.000000000 -0700
+++ nginx_upload_module-2.2.0.new/ngx_http_upload_module.c 2011-08-03
11:30:43.000000000 -0700
@@ -953,6 +953,7 @@
ngx_file_t *file = &u->output_file;
ngx_path_t *path = ulcf->store_path;
+ ngx_path_t *state_path = ulcf->state_store_path;
uint32_t n;
ngx_uint_t i;
ngx_int_t rc;
@@ -999,18 +1000,19 @@
return NGX_UPLOAD_NOMEM;
}
- u->state_file.name.len = file->name.len + sizeof(".state") - 1;
+ u->state_file.name.len = store_path->name.len + 1 +
store_path->len + (u->session_id.len != 0 ? u->session_id.len : 10) +
sizeof(".state") - 1;
u->state_file.name.data = ngx_palloc(u->request->pool,
u->state_file.name.len + 1);
if(u->state_file.name.data == NULL)
return NGX_UPLOAD_NOMEM;
- ngx_memcpy(u->state_file.name.data, file->name.data,
file->name.len);
+ ngx_memcpy(u->state_file.name.data, state_path->name.data,
state_path->name.len);
/*
* NOTE: we add terminating zero for system calls
*/
- ngx_memcpy(u->state_file.name.data + file->name.len, ".state",
sizeof(".state") - 1 + 1);
+ ngx_sprintf(u->state_file.name.data + state_path->name.len,
+ "%V.state%Z", &u->session_id);
ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
"hashed path of state file: %s",
u->state_file.name.data);
_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://mailman.nginx.org/mailman/listinfo/nginx-ru
|