From 9cf596c67b83eb690d8776ee500ade221af8e47d Mon Sep 17 00:00:00 2001 From: Konstantinos Kallas Date: Mon, 17 Jul 2017 09:59:38 +0300 Subject: Change the persistent data structure from a record to a proplist This is done so that possible future updates to the data structure don't break existing code. With this change it will be possible to update the data structure and keep the same old persistent data file, which will still have the expected list format but with more properties --- src/ejabberd_acme.erl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ejabberd_acme.erl b/src/ejabberd_acme.erl index 029f13edd..5d0608c93 100644 --- a/src/ejabberd_acme.erl +++ b/src/ejabberd_acme.erl @@ -401,19 +401,19 @@ is_error(_) -> false. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% data_empty() -> - #data{}. + []. -data_get_account(#data{account = Account}) -> - case Account of - #data_acc{id = AccId, key = PrivateKey} -> +data_get_account(Data) -> + case lists:keyfind(account, 1, Data) of + {account, #data_acc{id = AccId, key = PrivateKey}} -> {ok, AccId, PrivateKey}; - none -> + false -> none end. -data_set_account(Data = #data{}, {AccId, PrivateKey}) -> - NewAcc = #data_acc{id = AccId, key = PrivateKey}, - Data#data{account = NewAcc}. +data_set_account(Data, {AccId, PrivateKey}) -> + NewAcc = {account, #data_acc{id = AccId, key = PrivateKey}}, + lists:keystore(account, 1, Data, NewAcc). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- cgit v1.2.3