From 5fbcfabd883a2d153f04a22a261af46a86599ed1 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Mon, 2 Feb 2015 19:38:32 +0300 Subject: [PATCH] Core: supported directory skipping in ngx_walk_tree(). If pre_tree_handler() returns NGX_DECLINED, the directory is ignored. --- src/core/ngx_file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c index 8657d69ed..dc2259634 100644 --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -1047,10 +1047,18 @@ ngx_walk_tree(ngx_tree_ctx_t *ctx, ngx_str_t *tree) ctx->access = ngx_de_access(&dir); ctx->mtime = ngx_de_mtime(&dir); - if (ctx->pre_tree_handler(ctx, &file) == NGX_ABORT) { + rc = ctx->pre_tree_handler(ctx, &file); + + if (rc == NGX_ABORT) { goto failed; } + if (rc == NGX_DECLINED) { + ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, + "tree skip dir \"%s\"", file.data); + continue; + } + if (ngx_walk_tree(ctx, &file) == NGX_ABORT) { goto failed; }