From 9834f549911e2485ba0b35b7cefc89c0084d1f28 Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Thu, 21 Mar 2013 21:05:01 -0400 Subject: [PATCH] Cover a few more corner cases when encoding cache size and other values to config strings. --- src/riak_kv_wterl_backend.erl | 6 ++++-- src/wterl.erl | 12 +++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/riak_kv_wterl_backend.erl b/src/riak_kv_wterl_backend.erl index e88a9d5..849621e 100644 --- a/src/riak_kv_wterl_backend.erl +++ b/src/riak_kv_wterl_backend.erl @@ -561,8 +561,10 @@ size_cache(RequestedSize) -> application:set_env(wterl, cache_size, FinalGuess), lager:info("Using cache size of ~p for WiredTiger storage backend.", [FinalGuess]), FinalGuess; - Value -> - Value + Value when is_list(Value) -> + Value; + Value when is_number(Value) -> + integer_to_list(Value) end, Size. diff --git a/src/wterl.erl b/src/wterl.erl index 61ffa89..dc19fd5 100644 --- a/src/wterl.erl +++ b/src/wterl.erl @@ -320,12 +320,22 @@ config_encode(config, Value) -> list_to_binary(["(", config_to_bin(Value, []), ")"]); config_encode(list, Value) -> list_to_binary(["(", string:join(Value, ","), ")"]); -config_encode(string, Value) -> +config_encode(string, Value) when is_list(Value) -> list_to_binary(Value); +config_encode(string, Value) when is_number(Value) -> + list_to_binary(integer_to_list(Value)); config_encode(bool, true) -> <<"true">>; +config_encode(bool, Value) when is_number(Value) andalso Value =/= 0 -> + <<"true">>; +config_encode(bool, "true") -> + <<"true">>; config_encode(bool, false) -> <<"false">>; +config_encode(bool, 0) -> + <<"false">>; +config_encode(bool, "false") -> + <<"false">>; config_encode(_Type, _Value) -> invalid.