Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recursive directory listing in jesse database #45

Merged
merged 2 commits into from
Mar 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions src/jesse_database.erl
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,15 @@ list_outdated(Path) ->
lists:filter(fun is_outdated/1, Files)
end.

%% @doc Recursively lists all regular files from a directory `Dir`.
%% @private
list_dir(Path0) ->
{ok, Listing} = file:list_dir(Path0),
lists:foldl( fun([], Acc) ->
Acc;
(Filename, Acc) ->
Path = filename:join([Path0, Filename]),
case filelib:is_dir(Path) of
true ->
[list_dir(Path) | Acc];
false ->
[Path | Acc]
end
end
, []
, Listing
).
list_dir(Dir) ->
filelib:fold_files( Dir
, "^.*$" %% Allow any regular file.
, true
, fun(Path, Acc) -> [Path | Acc] end
, []
).

%% @doc Checks if a schema file `Filename' has an outdated cache entry.
%% @private
Expand Down