Skip to content

Commit

Permalink
Remove state file at successful completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Valery Kholodkov committed Aug 3, 2010
1 parent 332498d commit 22930ad
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ngx_http_upload_module.c
Expand Up @@ -958,7 +958,10 @@ static ngx_int_t ngx_http_upload_start_handler(ngx_http_upload_ctx_t *u) { /* {{

ngx_memcpy(u->state_file.name.data, file->name.data, file->name.len);

ngx_memcpy(u->state_file.name.data + file->name.len, ".state", sizeof(".state"));
/*
* NOTE: we add terminating zero for system calls
*/
ngx_memcpy(u->state_file.name.data + file->name.len, ".state", sizeof(".state") - 1 + 1);

ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
"hashed path of state file: %s", u->state_file.name.data);
Expand Down Expand Up @@ -1191,6 +1194,12 @@ static void ngx_http_upload_finish_handler(ngx_http_upload_ctx_t *u) { /* {{{ */

return;
}

if(ngx_delete_file(u->state_file.name.data) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "failed to remove state file \"%V\"", &u->state_file.name);
} else {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, "removed state file \"%V\"", &u->state_file.name);
}
}

ngx_log_error(NGX_LOG_INFO, r->connection->log, 0
Expand Down

0 comments on commit 22930ad

Please sign in to comment.