Do not stop booting if apps path is unavailable (#1812)

This commit is contained in:
José Valim 2023-03-21 12:33:53 +01:00 committed by GitHub
parent 2e51cb82f6
commit 4b8834c599
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 28 deletions

View file

@ -152,7 +152,7 @@ defmodule Livebook do
config :livebook, :data_path, data_path
end
if apps_path = Livebook.Config.readable_dir!("LIVEBOOK_APPS_PATH") do
if apps_path = System.get_env("LIVEBOOK_APPS_PATH") do
config :livebook, :apps_path, apps_path
end

View file

@ -107,6 +107,10 @@ defmodule Livebook.Apps do
pattern = Path.join([path, "**", "*.livemd"])
paths = Path.wildcard(pattern)
if paths == [] do
Logger.warning("No .livemd files were found for deployment at #{path}")
end
for path <- paths do
markdown = File.read!(path)
{notebook, warnings} = Livebook.LiveMarkdown.notebook_from_livemd(markdown)

View file

@ -262,33 +262,6 @@ defmodule Livebook.Config do
end
end
@doc """
Parses and validates dir from env.
"""
def readable_dir!(env) do
if dir = System.get_env(env) do
readable_dir!(env, dir)
end
end
@doc """
Validates `dir` within context.
"""
def readable_dir!(context, dir) do
if readable_dir?(dir) do
Path.expand(dir)
else
abort!("expected #{context} to be a readable directory: #{dir}")
end
end
defp readable_dir?(path) do
case File.stat(path) do
{:ok, %{type: :directory, access: access}} when access in [:read_write, :read] -> true
_ -> false
end
end
@doc """
Parses and validates the secret from env.
"""