updated mnesia_unixfs
This commit is contained in:
@@ -95,6 +95,8 @@
|
|||||||
%%%
|
%%%
|
||||||
%%% === UFS2 (OpenBSD) ===
|
%%% === UFS2 (OpenBSD) ===
|
||||||
%%%
|
%%%
|
||||||
|
%%% Filename limit: 127 characters
|
||||||
|
%%%
|
||||||
%%% === Hammer (DragonFlyBSD) ===
|
%%% === Hammer (DragonFlyBSD) ===
|
||||||
%%%
|
%%%
|
||||||
%%% === ZFS ===
|
%%% === ZFS ===
|
||||||
@@ -106,6 +108,9 @@
|
|||||||
% -behavior(gen_server).
|
% -behavior(gen_server).
|
||||||
-include_lib("kernel/include/logger.hrl").
|
-include_lib("kernel/include/logger.hrl").
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
% -record(file, { name = undefined :: term()
|
||||||
|
% , content = <<>> :: binary()
|
||||||
|
% }).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% callback from lib/mnesia/src/mnesia_backend_type.erl
|
%% callback from lib/mnesia/src/mnesia_backend_type.erl
|
||||||
@@ -330,7 +335,11 @@ delete_table(Alias, Table) ->
|
|||||||
|
|
||||||
fixtable(Alias, Table, Bool) ->
|
fixtable(Alias, Table, Bool) ->
|
||||||
?LOG_DEBUG("~p",[{?MODULE, self(), fixtable, [Alias, Table, Bool]}]),
|
?LOG_DEBUG("~p",[{?MODULE, self(), fixtable, [Alias, Table, Bool]}]),
|
||||||
throw(todo).
|
case Bool of
|
||||||
|
true -> [];
|
||||||
|
false -> []
|
||||||
|
end.
|
||||||
|
% throw(todo).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% @doc called by `mnesia_index:init_ext_index/5'.
|
%% @doc called by `mnesia_index:init_ext_index/5'.
|
||||||
@@ -386,7 +395,13 @@ is_index_consistent(Alias, IndexTag) ->
|
|||||||
|
|
||||||
info(TypeAlias, Table, Item) ->
|
info(TypeAlias, Table, Item) ->
|
||||||
?LOG_DEBUG("~p",[{?MODULE, self(), into, [TypeAlias, Table, Item]}]),
|
?LOG_DEBUG("~p",[{?MODULE, self(), into, [TypeAlias, Table, Item]}]),
|
||||||
throw(todo).
|
case Item of
|
||||||
|
size -> 0;
|
||||||
|
memory -> 0;
|
||||||
|
file_size -> 0
|
||||||
|
end.
|
||||||
|
|
||||||
|
% throw(todo).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% @doc Called by
|
%% @doc Called by
|
||||||
@@ -413,10 +428,15 @@ insert(TypeAlias, Table, Object) ->
|
|||||||
TablePath = filename:join(MnesiaDirectory, TableString),
|
TablePath = filename:join(MnesiaDirectory, TableString),
|
||||||
Key = element(2, Object),
|
Key = element(2, Object),
|
||||||
Value = element(3, Object),
|
Value = element(3, Object),
|
||||||
KeyEncoded = binary:encode_hex(crypto:hash(sha256,term_to_binary(Key, [deterministic]))),
|
KeyEncoded = binary:encode_hex(term_to_binary(Key, [deterministic, compressed])),
|
||||||
KeyPath = filename:join(TablePath, KeyEncoded),
|
KeyPath = filename:join(TablePath, KeyEncoded),
|
||||||
|
case byte_size(KeyEncoded) < 128 of
|
||||||
|
true ->
|
||||||
file:write_file(KeyPath, term_to_binary(Value)),
|
file:write_file(KeyPath, term_to_binary(Value)),
|
||||||
ok.
|
ok;
|
||||||
|
false ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% @doc Called by
|
%% @doc Called by
|
||||||
@@ -440,14 +460,19 @@ lookup(TypeAlias, Table, Key) ->
|
|||||||
TableString = atom_to_list(Table),
|
TableString = atom_to_list(Table),
|
||||||
MnesiaDirectory = mnesia_monitor:get_env(dir),
|
MnesiaDirectory = mnesia_monitor:get_env(dir),
|
||||||
TablePath = filename:join(MnesiaDirectory, TableString),
|
TablePath = filename:join(MnesiaDirectory, TableString),
|
||||||
KeyEncoded = binary:encode_hex(crypto:hash(sha256,term_to_binary(Key, [deterministic]))),
|
KeyEncoded = binary:encode_hex(term_to_binary(Key, [deterministic, compressed])),
|
||||||
KeyPath = filename:join(TablePath, KeyEncoded),
|
KeyPath = filename:join(TablePath, KeyEncoded),
|
||||||
|
case byte_size(KeyEncoded) < 128 of
|
||||||
|
true ->
|
||||||
case file:read_file(KeyPath) of
|
case file:read_file(KeyPath) of
|
||||||
{ok, File} ->
|
{ok, File} ->
|
||||||
Value = binary_to_term(File),
|
Value = binary_to_term(File),
|
||||||
{Table, Key, Value};
|
{Table, Key, Value};
|
||||||
Elsewise ->
|
Elsewise ->
|
||||||
Elsewise
|
Elsewise
|
||||||
|
end;
|
||||||
|
false ->
|
||||||
|
{Table, Key, []}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
@@ -608,7 +633,15 @@ select(Continuation) ->
|
|||||||
|
|
||||||
select(TypeAlias, Table, Pattern) ->
|
select(TypeAlias, Table, Pattern) ->
|
||||||
?LOG_DEBUG("~p",[{?MODULE, self(), select, [TypeAlias, Table, Pattern]}]),
|
?LOG_DEBUG("~p",[{?MODULE, self(), select, [TypeAlias, Table, Pattern]}]),
|
||||||
throw(todo).
|
TableString = atom_to_list(Table),
|
||||||
|
MnesiaDirectory = mnesia_monitor:get_env(dir),
|
||||||
|
TablePath = filename:join(MnesiaDirectory , TableString),
|
||||||
|
case file:list_dir(TablePath) of
|
||||||
|
{ok, Files} ->
|
||||||
|
[ binary_to_term(binary:decode_hex(list_to_binary(File))) || File <- Files ];
|
||||||
|
Elsewise -> Elsewise
|
||||||
|
end.
|
||||||
|
% throw(todo).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% @doc
|
%% @doc
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [debug_info]}.
|
||||||
{deps, []}.
|
{deps, [{berty, {git, "https://github.com/erlang-punch/berty", {branch, main}}}
|
||||||
|
]}.
|
||||||
|
|
||||||
{relx, [{release, {mnesia_backends, "0.1.0"},
|
{relx, [{release, {mnesia_backends, "0.1.0"},
|
||||||
[mnesia_backends,
|
[mnesia_backends,
|
||||||
|
|||||||
13
rebar.lock
13
rebar.lock
@@ -1 +1,12 @@
|
|||||||
[].
|
{"1.2.0",
|
||||||
|
[{<<"berty">>,
|
||||||
|
{git,"https://github.com/erlang-punch/berty",
|
||||||
|
{ref,"970d808d10f8d4d9a803de29768b343c3e1e4457"}},
|
||||||
|
0},
|
||||||
|
{<<"proper">>,{pkg,<<"proper">>,<<"1.4.0">>},1}]}.
|
||||||
|
[
|
||||||
|
{pkg_hash,[
|
||||||
|
{<<"proper">>, <<"89A44B8C39D28BB9B4BE8E4D715D534905B325470F2E0EC5E004D12484A79434">>}]},
|
||||||
|
{pkg_hash_ext,[
|
||||||
|
{<<"proper">>, <<"18285842185BD33EFBDA97D134A5CB5A0884384DB36119FEE0E3CFA488568CBB">>}]}
|
||||||
|
].
|
||||||
|
|||||||
Reference in New Issue
Block a user