Add geef_odb:write
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
-module(geef).
|
||||
-export([hex_to_raw/1, reference_list/1,
|
||||
reference_to_id/2, reference_glob/2, reference_lookup/2, reference_resolve/1,
|
||||
reference_target/1, reference_type/1, odb_object_exists/2]).
|
||||
reference_target/1, reference_type/1, odb_object_exists/2, odb_write/3]).
|
||||
|
||||
% repository operations
|
||||
-export([repository_get_path/1, repository_get_odb/1, repository_open/1, repository_init/2,
|
||||
@@ -65,6 +65,10 @@ reference_type(_Handle) ->
|
||||
odb_object_exists(_Val, _Val) ->
|
||||
nif_error(?LINE).
|
||||
|
||||
-spec odb_write(term, iolist(), atom()) -> term.
|
||||
odb_write(_Handle, _Contents, _Type) ->
|
||||
nif_error(?LINE).
|
||||
|
||||
oid_fmt(_Oid) ->
|
||||
nif_error(?LINE).
|
||||
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
-module(geef_odb).
|
||||
-export([exists/2]).
|
||||
-export([exists/2, write/3]).
|
||||
|
||||
-include("geef_records.hrl").
|
||||
|
||||
-spec exists(odb(), string()) -> boolean().
|
||||
exists(#odb{handle=Handle}, Sha) ->
|
||||
geef:odb_object_exists(Handle, Sha).
|
||||
|
||||
-spec write(odb(), iolist(), atom()) -> {ok, oid()} | {error, term}.
|
||||
write(#odb{handle=Handle}, Contents, Type) ->
|
||||
case geef:odb_write(Handle, Contents, Type) of
|
||||
{ok, Oid} ->
|
||||
{ok, #oid{oid=Oid}};
|
||||
Other ->
|
||||
Other
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user