mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-12-26 09:22:00 +08:00
Support config of the root path for storing notebooks (#191)
This adds a `:root_path` key to the application environment so that file dialogs can default to known location where notebooks are stored.
This commit is contained in:
parent
a9c8e20775
commit
3a19021983
3 changed files with 10 additions and 2 deletions
|
@ -12,4 +12,12 @@ defmodule Livebook.Config do
|
|||
{:longnames, _name} -> false
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Return the root path for persisting notebooks.
|
||||
"""
|
||||
@spec root_path() :: binary()
|
||||
def root_path() do
|
||||
Application.get_env(:livebook, :root_path, File.cwd!())
|
||||
end
|
||||
end
|
||||
|
|
|
@ -160,7 +160,7 @@ defmodule LivebookWeb.HomeLive do
|
|||
|
||||
def handle_info(_message, socket), do: {:noreply, socket}
|
||||
|
||||
defp default_path(), do: File.cwd!() <> "/"
|
||||
defp default_path(), do: Livebook.Config.root_path() <> "/"
|
||||
|
||||
defp sort_session_summaries(session_summaries) do
|
||||
Enum.sort_by(session_summaries, & &1.notebook_name)
|
||||
|
|
|
@ -89,7 +89,7 @@ defmodule LivebookWeb.SessionLive.PersistenceComponent do
|
|||
end
|
||||
|
||||
defp default_path() do
|
||||
File.cwd!() |> Path.join("notebook")
|
||||
Livebook.Config.root_path() |> Path.join("notebook")
|
||||
end
|
||||
|
||||
defp path_savable?(nil, _running_paths), do: true
|
||||
|
|
Loading…
Reference in a new issue