summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-07-11 18:39:48 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-07-11 18:39:48 +0200
commitb6e8cc8606b288970d7cdf577c6dd36950adac91 (patch)
treec8388d48e7d3fb8c8622181e4f0a4376477278b4 /src/shared/io
parentacb9dd3220a3edcac93aa11d1d74d008e2fb23ed (diff)
Separates read and write permissions.
Diffstat (limited to 'src/shared/io')
-rw-r--r--src/shared/io/shr_database.erl40
-rw-r--r--src/shared/io/shr_timed_cache.erl2
2 files changed, 31 insertions, 11 deletions
diff --git a/src/shared/io/shr_database.erl b/src/shared/io/shr_database.erl
index bffcb9f..60327a5 100644
--- a/src/shared/io/shr_database.erl
+++ b/src/shared/io/shr_database.erl
@@ -10,8 +10,8 @@
-export
(
[
- insert/4,
- fetch/2,
+ insert/5,
+ fetch/3,
commit/1
]
).
@@ -34,21 +34,41 @@ do_remote_operation (Op, Params) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec insert (atom(), any(), shr_db_user:permission(), any()) -> 'ok'.
-insert (DB, ObjectID, Permission, Value) ->
- {atomic, _} = do_remote_operation(insert, [DB, ObjectID, Permission, Value]),
+-spec insert
+ (
+ atom(),
+ any(),
+ shr_db_user:permission(),
+ shr_db_user:permission(),
+ any()
+ )
+ -> 'ok'.
+insert (DB, ObjectID, ReadPerm, WritePerm, Value) ->
+ {atomic, _} =
+ do_remote_operation(insert, [DB, ObjectID, ReadPerm, WritePerm, Value]),
+
io:format
(
"~nshr_database:insert(~p) -> ok.~n",
- [{DB, ObjectID, Permission, Value}]
+ [{DB, ObjectID, ReadPerm, WritePerm, Value}]
),
ok.
--spec fetch (atom(), any()) -> ({'ok', any()} | 'not_found').
-fetch (DB, ObjectID) ->
- {atomic, Reply} = do_remote_operation(read, [DB, ObjectID]),
- io:format("~nshr_database:fetch(~p) -> ~p.~n", [{DB, ObjectID}, Reply]),
+-spec fetch
+ (
+ atom(),
+ any(),
+ shr_db_user:user()
+ )
+ -> ({'ok', any()} | 'not_found').
+fetch (DB, ObjectID, Cred) ->
+ {atomic, Reply} = do_remote_operation(read, [DB, ObjectID, Cred]),
+ io:format
+ (
+ "~nshr_database:fetch(~p) -> ~p.~n",
+ [{DB, ObjectID, Cred}, Reply]
+ ),
Reply.
-spec commit (shr_db_query:type()) -> 'ok'.
diff --git a/src/shared/io/shr_timed_cache.erl b/src/shared/io/shr_timed_cache.erl
index b89de48..de3d094 100644
--- a/src/shared/io/shr_timed_cache.erl
+++ b/src/shared/io/shr_timed_cache.erl
@@ -38,7 +38,7 @@
-spec add_to_cache (atom(), any(), any()) -> any().
add_to_cache (DB, Owner, ObjectID) ->
{ok, TimerPID} = gen_server:start(?MODULE, {DB, {Owner, ObjectID}}, []),
- {ok, Data} = shr_database:fetch(DB, ObjectID),
+ {ok, Data} = shr_database:fetch(DB, ObjectID, Owner),
ets:insert(DB, {{Owner, ObjectID}, TimerPID, Data}),
Data.