Skip to content

Commit

Permalink
Merge pull request #45 from JakubCzarniecki/fix-empty-list-dir
Browse files Browse the repository at this point in the history
Fix recursive directory listing in jesse database
  • Loading branch information
andreineculau committed Mar 11, 2017
2 parents 84a6e93 + 3b874ef commit c4da4a6
Showing 1 changed file with 8 additions and 16 deletions.
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

0 comments on commit c4da4a6

Please sign in to comment.