Fix cache_dir() problem, made it configurable
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
%% -*- mode: erlang; erlang-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
-module(gmhc_app).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-behaviour(application).
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
-module(gmhc_config).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-export([ load_config/0
|
||||
, get_config/1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-module(gmhc_config_schema).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-export([ schema/0
|
||||
, to_json/0
|
||||
@@ -51,6 +51,7 @@ schema() ->
|
||||
, pool => pool()
|
||||
, pool_admin => pool_admin()
|
||||
, workers => workers()
|
||||
, cache_dir => str(#{description => <<"Location of cache, default is 'setup:data_dir()'">>})
|
||||
, report => str(#{ enum => [<<"debug">>, <<"progress">>, <<"silent">>]
|
||||
, default => <<"silent">>
|
||||
, description => <<"Progress reporting">> })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-module(gmhc_connector).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-behaviour(gen_server).
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-module(gmhc_connectors_sup).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
-behavior(supervisor).
|
||||
|
||||
-export([ start_link/0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-module(gmhc_counters).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-export([ initialize/0 ]).
|
||||
|
||||
|
||||
+23
-3
@@ -1,9 +1,12 @@
|
||||
-module(gmhc_eureka).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-export([get_pool_address/0]).
|
||||
-export([cache_good_address/1,
|
||||
invalidate_cache/0]).
|
||||
invalidate_cache/0,
|
||||
cached_address/0,
|
||||
cache_filename/0,
|
||||
cache_dir/0]).
|
||||
|
||||
-include_lib("kernel/include/logger.hrl").
|
||||
-include("gmhc_events.hrl").
|
||||
@@ -99,10 +102,27 @@ cache_filename() ->
|
||||
cache_filename(cache_info()).
|
||||
|
||||
cache_filename(#{network := Network, pubkey := Pubkey}) ->
|
||||
Path = filename:join(setup:data_dir(), Network),
|
||||
Path = filename:join(cache_dir(), Network),
|
||||
<<"ak_", PKShort:8/binary, _/binary>> = Pubkey,
|
||||
filename:join(Path, "gmhc_eureka." ++ binary_to_list(PKShort) ++ ".cache").
|
||||
|
||||
cache_dir() ->
|
||||
case gmconfig:find_config([<<"cache_dir">>]) of
|
||||
{ok, D} ->
|
||||
D;
|
||||
undefined ->
|
||||
case setup_zomp:is_zomp_context() of
|
||||
true ->
|
||||
cache_dir_zomp();
|
||||
false ->
|
||||
filename:join(setup:data_dir(), "gmhive.cache")
|
||||
end
|
||||
end.
|
||||
|
||||
cache_dir_zomp() ->
|
||||
#{package_id := {Realm, App, _}} = zx_daemon:meta(),
|
||||
filename:join(zx_lib:ppath(var, {Realm, App}), "gmhive.cache").
|
||||
|
||||
get_pool_address_() ->
|
||||
case gmconfig:find_config([<<"pool_admin">>, <<"url">>], [user_config]) of
|
||||
{ok, URL0} ->
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
-module(gmhc_events).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-export([subscribe/1,
|
||||
ensure_subscribed/1,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-module(gmhc_handler).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
-behavior(gen_server).
|
||||
|
||||
-export([ start_link/0
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
-module(gmhc_lib).
|
||||
-vsn("0.8.3").
|
||||
|
||||
-export([ rand/1 ]).
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
-module(gmhc_server).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-behaviour(gen_server).
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
%% -*- mode: erlang; erlang-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
-module(gmhc_sup).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-behaviour(supervisor).
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(gmhc_workers).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-export([
|
||||
get_worker_configs/0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-module(gmhive_client).
|
||||
-vsn("0.6.1").
|
||||
-vsn("0.8.3").
|
||||
|
||||
-export([ connect/1
|
||||
, disconnect/1
|
||||
|
||||
Reference in New Issue
Block a user