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