Browse files

If init/1 provider's callback returns anything else than #amqpfs_prov…

…ider_state, use it as a value for .extra
  • Loading branch information...
1 parent 07d2290 commit f8d6d5b654f7c79e3be8e4e873e5c48046920813 Yurii Rashkovskii committed Jan 5, 2010
Showing with 12 additions and 6 deletions.
  1. +1 −1 samples/ramfs_amqpfs_provider.erl
  2. +7 −1 src/amqpfs_provider.erl
  3. +1 −1 src/dot_amqpfs_provider.erl
  4. +3 −3 src/root_amqpfs_provider.erl
View
2 samples/ramfs_amqpfs_provider.erl
@@ -30,7 +30,7 @@ init(#amqpfs_provider_state{ args = Args } = State) ->
attrs = ets:new(ramfs_attrs, [public, set])
},
amqpfs_provider:announce(directory, proplists:get_value(dir, Args, "/ramfs"), State),
- State#amqpfs_provider_state{ extra = RamFS }.
+ RamFS.
list_dir(Path, #amqpfs_provider_state{ extra = RamFS }) ->
#ramfs{ files = Files } = RamFS,
View
8 src/amqpfs_provider.erl
@@ -32,7 +32,13 @@ start(Module, Args) ->
init([Module, Args]) ->
State0 = #amqpfs_provider_state{ module = Module, args = Args},
State1 = setup(State0),
- State2 = call_module(init, [State1], State1),
+ State2 =
+ case call_module(init, [State1], State1) of
+ #amqpfs_provider_state{}=S ->
+ S;
+ Other ->
+ State1#amqpfs_provider_state{ extra = Other }
+ end,
{ok, State2}.
View
2 src/dot_amqpfs_provider.erl
@@ -18,7 +18,7 @@ init(State) ->
RequestedState
end,
amqpfs_provider:announce(directory, "/.amqpfs", State),
- State#amqpfs_provider_state{ extra = AmqpfsState }.
+ AmqpfsState.
list_dir([".amqpfs"], _State) ->
[{"version", {file, on_demand}},{"providers",{directory, on_demand}},{"announcements",{file, on_demand}}];
View
6 src/root_amqpfs_provider.erl
@@ -30,9 +30,9 @@ init(#amqpfs_provider_state{ channel = Channel }=State) ->
no_ack = true,
exclusive = false,
nowait = false}),
- State1 = State#amqpfs_provider_state { extra = #root_amqpfs_provider_extra{ items = ets:new(root_fs_items, [public, set]) } },
- amqpfs_provider:announce(directory, "/", State1),
- State1.
+ amqpfs_provider:announce(directory, "/", State),
+ #root_amqpfs_provider_extra{ items = ets:new(root_fs_items, [public, set]) }.
+
list_dir([], #amqpfs_provider_state{ extra = Extra }) ->
Items = Extra#root_amqpfs_provider_extra.items,

0 comments on commit f8d6d5b

Please sign in to comment.