diff --git a/src/core/resolver/hb_cache.erl b/src/core/resolver/hb_cache.erl index 082ae060f..c831a1df1 100644 --- a/src/core/resolver/hb_cache.erl +++ b/src/core/resolver/hb_cache.erl @@ -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. @@ -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(), diff --git a/src/core/store/hb_store_lmdb.erl b/src/core/store/hb_store_lmdb.erl index a5b649ffc..4fe01bc59 100644 --- a/src/core/store/hb_store_lmdb.erl +++ b/src/core/store/hb_store_lmdb.erl @@ -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) ->