Handle the activity/4 return arguments better.

main
absc 2024-10-12 21:31:52 +00:00
parent cbdbdb6c32
commit 217117a289
1 changed files with 5 additions and 20 deletions

View File

@ -709,10 +709,7 @@ handle_call({read, Bucket, Key}, _From, State) ->
mnesia:read(Bucket, Key)
end,
case mnesia:activity(transaction, F, [], mnesia_frag) of
{atomic, R} -> {reply, {ok, R}, State};
{aborted, Reason} -> {reply, {error, Reason}, State}
end;
{reply, mnesia:activity(transaction, F, [], mnesia_frag), State};
%
% Write callbacks.
@ -723,10 +720,7 @@ handle_call({delete, Bucket, Key}, _From, State) ->
mnesia:delete({Bucket, Key})
end,
case mnesia:activity(transaction, F, [], mnesia_frag) of
{atomic, ok} -> {reply, ok, State};
{aborted, Reason} -> {reply, {error, Reason}, State}
end;
{reply, mnesia:activity(transaction, F, [], mnesia_frag), State};
handle_call({delete_set, Bucket, Metadata}, _From, State) ->
Q = qlc:q([X || X <- mnesia:table(Bucket), filter(Metadata, X#object.metadata)]),
@ -737,10 +731,7 @@ handle_call({delete_set, Bucket, Metadata}, _From, State) ->
delete_matching(Bucket, Recs)
end,
case mnesia:activity(transaction, F, [], mnesia_frag) of
{atomic, ok} -> {reply, ok, State};
{aborted, Reason} -> {reply, {error, Reason}, State}
end;
{reply, mnesia:activity(transaction, F, [], mnesia_frag), State};
handle_call({write, Bucket, Key, Term}, _From, State) ->
handle_call({write, Bucket, Key, Term, []}, _From, State);
@ -751,10 +742,7 @@ handle_call({write, Bucket, Key, Term, Metadata}, _From, State) ->
mnesia:write(Bucket, R, write)
end,
case mnesia:activity(transaction, F, [], mnesia_frag) of
{atomic, _} -> {reply, ok, State};
{aborted, Reason} -> {reply, {error, Reason}, State}
end.
{reply, mnesia:activity(transaction, F, [], mnesia_frag), State}.
handle_cast(_Msg, State) -> {noreply, State}.
@ -806,10 +794,7 @@ search(Bucket, Metadata) ->
qlc:e(Q)
end,
case mnesia:activity(transaction, F, [], mnesia_frag) of
{atomic, L} -> {ok, L};
{aborted, Reason} -> {error, Reason}
end.
{ok, mnesia:activity(transaction, F, [], mnesia_frag)}.
%
% A record is reported if and only if it contains all the key-value