Create home and data_path directories if missing (#1003)

* Create home and data_path directories if missing

* Update lib/livebook/config.ex

* Configure project-local data path for dev and test env

* Expand dev/test paths in compile config

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
This commit is contained in:
José Valim 2022-02-14 22:19:06 +01:00 committed by GitHub
parent 8836d6908c
commit 2c271e2efb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -71,3 +71,5 @@ config :phoenix, :plug_init_mode, :runtime
# Disable authentication mode during dev
config :livebook, :authentication_mode, :disabled
config :livebook, :data_path, Path.expand("tmp/livebook_data/dev")

View file

@ -14,6 +14,8 @@ config :logger, level: :warn
# Disable authentication mode during test
config :livebook, :authentication_mode, :disabled
config :livebook, :data_path, Path.expand("tmp/livebook_data/test")
# Use the embedded runtime in tests by default, so they
# are cheaper to run. Other runtimes can be tested by starting
# and setting them explicitly

View file

@ -6,7 +6,8 @@ defmodule Livebook.Application do
use Application
def start(_type, _args) do
ensure_local_filesystem!()
ensure_directories!()
set_local_filesystem!()
ensure_distribution!()
validate_hostname_resolution!()
set_cookie()
@ -55,7 +56,12 @@ defmodule Livebook.Application do
:ok
end
defp ensure_local_filesystem!() do
defp ensure_directories!() do
File.mkdir_p!(Livebook.Config.home())
File.mkdir_p!(Livebook.Config.data_path())
end
defp set_local_filesystem!() do
home =
Livebook.Config.home()
|> Livebook.FileSystem.Utils.ensure_dir_path()