Improve metadata storage (#37)

* Updated config path to specify metadata storage path

* Removed metadata column from DB, replacing it with filepath columns

* Updated app to store compressed metadata; automatically download thumbnails

* Ensured metadata is deleted when other files are deleted

* Updated docs

* Added inets to application start so http calls work in prod
This commit is contained in:
Kieran
2024-02-24 13:40:05 -08:00
committed by GitHub
parent e33a46bddc
commit 52c0a1742a
25 changed files with 370 additions and 61 deletions
+3 -1
View File
@@ -14,7 +14,9 @@ config :pinchflat,
yt_dlp_executable: System.find_executable("yt-dlp"),
yt_dlp_runner: Pinchflat.MediaClient.Backends.YtDlp.CommandRunner,
media_directory: "/downloads",
metadata_directory: Path.join([System.tmp_dir!(), "pinchflat", "metadata"]),
# The user may or may not store metadata for their needs, but the app will always store its copy
metadata_directory: "/config/metadata",
tmpfile_directory: Path.join([System.tmp_dir!(), "pinchflat", "data"]),
# Setting AUTH_USERNAME and AUTH_PASSWORD implies you want to use basic auth.
# If either is unset, basic auth will not be used.
basic_auth_username: System.get_env("AUTH_USERNAME"),
+2 -1
View File
@@ -2,7 +2,8 @@ import Config
config :pinchflat,
media_directory: Path.join([File.cwd!(), "tmp", "videos"]),
metadata_directory: Path.join([File.cwd!(), "tmp", "metadata"])
metadata_directory: Path.join([File.cwd!(), "tmp", "metadata"]),
tmpfile_directory: Path.join([File.cwd!(), "tmp", "tmpfiles"])
# Configure your database
config :pinchflat, Pinchflat.Repo,
+12 -9
View File
@@ -22,19 +22,24 @@ if System.get_env("PHX_SERVER") do
end
if config_env() == :prod do
database_path =
System.get_env("DATABASE_PATH") ||
config_path =
System.get_env("CONFIG_PATH") ||
raise """
environment variable DATABASE_PATH is missing.
For example: /etc/pinchflat/pinchflat.db
environment variable CONFIG_PATH is missing.
For example: /etc/pinchflat/config
"""
log_path = System.get_env("LOG_PATH", "log/pinchflat.log")
db_path = System.get_env("DATABASE_PATH", Path.join([config_path, "db", "pinchflat.db"]))
log_path = System.get_env("LOG_PATH", Path.join([config_path, "logs", "pinchflat.log"]))
metadata_path = System.get_env("METADATA_PATH", Path.join([config_path, "metadata"]))
config :pinchflat, yt_dlp_executable: System.find_executable("yt-dlp")
config :pinchflat,
yt_dlp_executable: System.find_executable("yt-dlp"),
metadata_directory: metadata_path,
dns_cluster_query: System.get_env("DNS_CLUSTER_QUERY")
config :pinchflat, Pinchflat.Repo,
database: database_path,
database: db_path,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "5")
# The secret key base is used to sign/encrypt cookies and other secrets.
@@ -63,8 +68,6 @@ if config_env() == :prod do
end
end
config :pinchflat, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
config :pinchflat, PinchflatWeb.Endpoint,
http: [
# Enable IPv6 and bind on all interfaces.
+2 -1
View File
@@ -4,7 +4,8 @@ config :pinchflat,
# Specifying backend data here makes mocking and local testing SUPER easy
yt_dlp_executable: Path.join([File.cwd!(), "/test/support/scripts/yt-dlp-mocks/repeater.sh"]),
media_directory: Path.join([System.tmp_dir!(), "test", "videos"]),
metadata_directory: Path.join([System.tmp_dir!(), "test", "metadata"])
metadata_directory: Path.join([System.tmp_dir!(), "test", "metadata"]),
tmpfile_directory: Path.join([System.tmp_dir!(), "test", "tmpfiles"])
config :pinchflat, Oban, testing: :manual