Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 14 additions & 1 deletion src/core/resolver/hb_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ list(Path, Opts) when is_map(Opts) and not is_map_key(<<"store-module">>, Opts)
list(Path, Store) ->
list(Path, Store, #{}).
list(Path, Store, Opts) ->
case hb_store:read(Store, Path, Opts) of
case hb_store:list(Store, Path, Opts) of
{ok, Names} -> Names;
{composite, Names} -> Names;
_ -> []
end.
Expand Down Expand Up @@ -1275,6 +1276,18 @@ write_with_only_read_only_store_test() ->
?assertMatch({ok, _}, write(<<"some-binary-payload">>, Opts)),
?assertMatch({ok, _}, write(#{ <<"hello">> => <<"world">> }, Opts)).

list_lmdb_children_without_group_marker_test() ->
Store = hb_test_utils:test_store(hb_store_lmdb, <<"legacy-list">>),
Opts = #{ <<"store">> => Store },
try
hb_store:reset(Store),
ok = hb_store:write(Store, #{ <<"legacy/1">> => <<"one">> }, Opts),
ok = hb_store:write(Store, #{ <<"legacy/2">> => <<"two">> }, Opts),
?assertEqual([<<"1">>, <<"2">>], lists:sort(list(<<"legacy">>, Opts)))
after
hb_store:reset(Store)
end.

%% @doc Run a specific test with a given store module.
run_test() ->
Store = hb_test_utils:test_store(),
Expand Down
5 changes: 3 additions & 2 deletions src/core/store/hb_store_lmdb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,14 @@ scope(_) -> scope().
%% @param Path Binary prefix to search for
%% @returns {ok, [Key]} list of matching keys, {error, Reason} on failure
list(Opts, #{ <<"list">> := Path }, _NodeOpts) ->
case read_resolved(Opts, hb_path:to_binary(Path)) of
PathBin = hb_path:to_binary(Path),
case read_resolved(Opts, PathBin) of
{ok, ResolvedPath, <<"group">>} ->
list_children(Opts, ResolvedPath);
{ok, _ResolvedPath, _Value} ->
{error, not_found};
not_found ->
{error, not_found}
list_children(Opts, PathBin)
end.

list_children(Opts, ResolvedPath) ->
Expand Down