Skip to content

Commit

Permalink
startup fixes (2600hz#2969)
Browse files Browse the repository at this point in the history
* check db result in fix_media_names

* ensure system databases in get_databases/0
  • Loading branch information
lazedo authored and fenollp committed Dec 10, 2016
1 parent 4bbb110 commit 823c8fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/kazoo_apps/src/kapps_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ refresh([Database|Databases], Pause, Total) ->
-spec get_databases() -> ne_binaries().
get_databases() ->
{'ok', Databases} = kz_datamgr:db_info(),
lists:sort(fun get_database_sort/2, Databases).
lists:sort(fun get_database_sort/2, lists:usort(Databases ++ ?KZ_SYSTEM_DBS)).

-spec get_database_sort(ne_binary(), ne_binary()) -> boolean().
get_database_sort(Db1, Db2) ->
Expand Down
12 changes: 8 additions & 4 deletions core/kazoo_media/src/kazoo_media_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,12 @@ fix_media_name(JObj) ->

-spec fix_media_names() -> any().
fix_media_names() ->
{'ok', JObjs} = kz_datamgr:all_docs(?KZ_MEDIA_DB),
case [ JObj || JObj <- JObjs, filter_media_names(JObj)] of
[] -> kapps_config:set(?CONFIG_CAT, <<"fix_media_names">>, 'false');
List -> lists:foreach(fun fix_media_name/1, List)
case kz_datamgr:all_docs(?KZ_MEDIA_DB) of
{'ok', JObjs} ->
case [ JObj || JObj <- JObjs, filter_media_names(JObj)] of
[] -> kapps_config:set(?CONFIG_CAT, <<"fix_media_names">>, 'false');
List -> lists:foreach(fun fix_media_name/1, List)
end;
{'error', Error} ->
lager:debug("error '~p' getting media names", [Error])
end.

0 comments on commit 823c8fc

Please sign in to comment.