Cover a few more corner cases when encoding cache size and other

values to config strings.
This commit is contained in:
Gregory Burd 2013-03-21 21:05:01 -04:00
parent 9302def7cc
commit 9834f54991
2 changed files with 15 additions and 3 deletions

View file

@ -561,8 +561,10 @@ size_cache(RequestedSize) ->
application:set_env(wterl, cache_size, FinalGuess), application:set_env(wterl, cache_size, FinalGuess),
lager:info("Using cache size of ~p for WiredTiger storage backend.", [FinalGuess]), lager:info("Using cache size of ~p for WiredTiger storage backend.", [FinalGuess]),
FinalGuess; FinalGuess;
Value -> Value when is_list(Value) ->
Value Value;
Value when is_number(Value) ->
integer_to_list(Value)
end, end,
Size. Size.

View file

@ -320,12 +320,22 @@ config_encode(config, Value) ->
list_to_binary(["(", config_to_bin(Value, []), ")"]); list_to_binary(["(", config_to_bin(Value, []), ")"]);
config_encode(list, Value) -> config_encode(list, Value) ->
list_to_binary(["(", string:join(Value, ","), ")"]); list_to_binary(["(", string:join(Value, ","), ")"]);
config_encode(string, Value) -> config_encode(string, Value) when is_list(Value) ->
list_to_binary(Value); list_to_binary(Value);
config_encode(string, Value) when is_number(Value) ->
list_to_binary(integer_to_list(Value));
config_encode(bool, true) -> config_encode(bool, true) ->
<<"true">>; <<"true">>;
config_encode(bool, Value) when is_number(Value) andalso Value =/= 0 ->
<<"true">>;
config_encode(bool, "true") ->
<<"true">>;
config_encode(bool, false) -> config_encode(bool, false) ->
<<"false">>; <<"false">>;
config_encode(bool, 0) ->
<<"false">>;
config_encode(bool, "false") ->
<<"false">>;
config_encode(_Type, _Value) -> config_encode(_Type, _Value) ->
invalid. invalid.