diff --git a/config/runtime.exs b/config/runtime.exs index 4e200df..6a7c95c 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -78,13 +78,21 @@ config :geo_therminator, api_device_reg_set_client_id: get_env("API_DEVICE_REG_SET_CLIENT_ID"), api_refresh: 10_000, - # Database directory for settings, relative to app HOME path - db_dir: get_env("DB_DIR", "db") + # Database directory for settings + db_dir: + Path.join( + if config_target() in [:ios, :android] do + System.get_env("HOME") + else + Application.app_dir(:geo_therminator, "priv") + end, + get_env("DB_DIR", "db") + ) if config_env() == :dev do config :geo_therminator, GeoTherminatorWeb.Endpoint, http: [ - 0 + port: 0 ] end diff --git a/lib/geo_therminator/application.ex b/lib/geo_therminator/application.ex index 22553fc..c144925 100644 --- a/lib/geo_therminator/application.ex +++ b/lib/geo_therminator/application.ex @@ -7,7 +7,7 @@ defmodule GeoTherminator.Application do @impl true def start(_type, _args) do - db_dir = System.get_env("HOME") |> Path.join(Application.get_env(:geo_therminator, :db_dir)) + db_dir = Application.get_env(:geo_therminator, :db_dir) children = [ {CubDB, name: GeoTherminator.DB, data_dir: db_dir},