From 217117a28909c2292c1329970f545f88fe5c77c9 Mon Sep 17 00:00:00 2001 From: absc Date: Sat, 12 Oct 2024 21:31:52 +0000 Subject: [PATCH] Handle the activity/4 return arguments better. --- storage/src/storage.erl | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/storage/src/storage.erl b/storage/src/storage.erl index d14cc39..5c7705f 100644 --- a/storage/src/storage.erl +++ b/storage/src/storage.erl @@ -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