get_url :: binary(),
service_url :: binary() | undefined,
thumbnail :: boolean(),
- slots = dict:new() :: term()}). % dict:dict() requires Erlang 17.
+ slots = #{} :: map()}).
-record(media_info,
{type :: binary(),
-spec add_slot(slot(), pos_integer(), timer:tref(), state()) -> state().
add_slot(Slot, Size, Timer, #state{slots = Slots} = State) ->
- NewSlots = dict:store(Slot, {Size, Timer}, Slots),
+ NewSlots = maps:put(Slot, {Size, Timer}, Slots),
State#state{slots = NewSlots}.
-spec get_slot(slot(), state()) -> {ok, {pos_integer(), timer:tref()}} | error.
get_slot(Slot, #state{slots = Slots}) ->
- dict:find(Slot, Slots).
+ maps:find(Slot, Slots).
-spec del_slot(slot(), state()) -> state().
del_slot(Slot, #state{slots = Slots} = State) ->
- NewSlots = dict:erase(Slot, Slots),
+ NewSlots = maps:remove(Slot, Slots),
State#state{slots = NewSlots}.
-spec slot_el(slot() | binary(), state() | binary(), binary()) -> xmlel().
access_hard_quota :: atom(),
max_days :: pos_integer() | infinity,
docroot :: binary(),
- disk_usage = dict:new() :: term(),
+ disk_usage = #{} :: map(),
timers :: [timer:tref()]}).
-type state() :: #state{}.
_ ->
0
end,
- OldSize = case dict:find({U, S}, DiskUsage) of
+ OldSize = case maps:find({U, S}, DiskUsage) of
{ok, Value} ->
Value;
error ->
enforce_quota(Path, Size, OldSize, SoftQuota, HardQuota)
end,
NewDiskUsage = if is_integer(NewSize) ->
- dict:store({U, S}, NewSize, DiskUsage);
+ maps:put({U, S}, NewSize, DiskUsage);
true ->
DiskUsage
end,