fix: added things around project folder pollution from program runs

This commit is contained in:
2026-05-29 21:45:15 +02:00
parent 3a77761f96
commit 9d5764b251
11 changed files with 122 additions and 23 deletions

View File

@@ -268,20 +268,25 @@ defmodule BDS.Projects do
not Repo.exists?(from project in Project, where: project.slug == ^slug)
end
defp repo_data_dir do
Application.fetch_env!(:bds, BDS.Repo)
|> Keyword.fetch!(:database)
|> Path.expand()
|> Path.dirname()
end
defp project_cache_root do
case Application.get_env(:bds, :project_cache_root) do
root when is_binary(root) -> Path.expand(root)
_other -> repo_data_dir()
# Private app-internal artifacts (e.g. the embeddings index) live under the
# OS private app directory — on macOS ~/Library/Application Support/bds —
# never inside the repo or a project's public folder. Colocating them with
# project_data_dir would pollute (and historically committed to) the repo.
_other -> private_app_dir()
end
end
defp private_app_dir do
case :filename.basedir(:user_config, "bds") do
path when is_list(path) -> List.to_string(path)
path -> path
end
|> Path.expand()
end
defp attr(attrs, key) do
cond do
Map.has_key?(attrs, key) -> Map.get(attrs, key)