]> git.kaiwu.me - nginx.git/commitdiff
Core: supported directory skipping in ngx_walk_tree().
authorRoman Arutyunyan <arut@nginx.com>
Mon, 2 Feb 2015 16:38:32 +0000 (19:38 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Mon, 2 Feb 2015 16:38:32 +0000 (19:38 +0300)
If pre_tree_handler() returns NGX_DECLINED, the directory is ignored.

src/core/ngx_file.c

index 8657d69edd36eeaba31f28e701c1d96704c14330..dc2259634f0f0ace3f5e5bc49220f5ab0812416a 100644 (file)
@@ -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;
             }