Skip to content

Commit

Permalink
Merge pull request #865 from 3scale/cli-filesystem-permission-error
Browse files Browse the repository at this point in the history
[cli] do not crash when listing unaccessible directories
  • Loading branch information
mikz authored Sep 3, 2018
2 parents 50b063b + c52896d commit 945a0d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## Fixed

- Capture permission errors when searching for files on filesystem [PR #865](https://github.com/3scale/apicast/pull/865)

## [3.3.0-beta1] - 2018-08-31

### Added
Expand Down
5 changes: 4 additions & 1 deletion gateway/src/apicast/cli/filesystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ local co_yield = coroutine.yield
local co_create = coroutine.create
local co_resume = coroutine.resume

local noop = function () end

--- Safely try to get directory iterator
local function ldir(dir)
local ok, iter, state = pcall(pl_path_dir, dir)

if ok then
return iter, state
else
return nil, iter
ngx.log(ngx.DEBUG, 'error listing directory: ', dir, ' err: ', iter)
return noop
end
end

Expand Down

0 comments on commit 945a0d9

Please sign in to comment.