Compare commits
3 Commits
v2024.5.15
...
v2024.5.16
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bf74a04e7 | |||
| 33040bba34 | |||
| b1a6a6a81f |
@@ -31,6 +31,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
||||
"""
|
||||
@impl true
|
||||
def init(state) do
|
||||
ensure_tmpfile_directory()
|
||||
reset_executing_jobs()
|
||||
create_blank_yt_dlp_files()
|
||||
create_blank_user_script_file()
|
||||
@@ -39,6 +40,14 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
||||
{:ok, state}
|
||||
end
|
||||
|
||||
defp ensure_tmpfile_directory do
|
||||
tmpfile_dir = Application.get_env(:pinchflat, :tmpfile_directory)
|
||||
|
||||
if !File.exists?(tmpfile_dir) do
|
||||
File.mkdir_p!(tmpfile_dir)
|
||||
end
|
||||
end
|
||||
|
||||
# If a node cannot gracefully shut down, the currently executing jobs get stuck
|
||||
# in the "executing" state. This is a problem because the job runner will not
|
||||
# pick them up again
|
||||
|
||||
@@ -24,11 +24,12 @@ defmodule Pinchflat.Utils.CliUtils do
|
||||
def wrap_cmd(command, args, passthrough_opts \\ [], opts \\ []) do
|
||||
wrapper_command = Path.join(:code.priv_dir(:pinchflat), "cmd_wrapper.sh")
|
||||
actual_command = [command] ++ args
|
||||
command_opts = set_command_opts() ++ passthrough_opts
|
||||
logging_arg_override = Keyword.get(opts, :logging_arg_override, Enum.join(args, " "))
|
||||
|
||||
Logger.info("[command_wrapper]: #{command} called with: #{logging_arg_override}")
|
||||
|
||||
{output, status} = System.cmd(wrapper_command, actual_command, passthrough_opts)
|
||||
{output, status} = System.cmd(wrapper_command, actual_command, command_opts)
|
||||
log_cmd_result(command, logging_arg_override, status, output)
|
||||
|
||||
{output, status}
|
||||
@@ -81,4 +82,13 @@ defmodule Pinchflat.Utils.CliUtils do
|
||||
|
||||
Logger.log(log_level, log_message)
|
||||
end
|
||||
|
||||
defp set_command_opts do
|
||||
# This resolves an issue where yt-dlp would attempt to write to a read-only directory
|
||||
# if you scanned a new video with `--windows-filenames` enabled. Hopefully can be removed
|
||||
# in the future.
|
||||
[
|
||||
cd: Application.get_env(:pinchflat, :tmpfile_directory)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
() => copied = false
|
||||
)
|
||||
"}>
|
||||
Copy Diagnotic Info
|
||||
Copy Diagnostic Info
|
||||
<span x-show="copied" x-transition.duration.150ms><.icon name="hero-check" class="ml-2 h-4 w-4" /></span>
|
||||
</.button>
|
||||
<.link href={~p"/download_logs"}>
|
||||
|
||||
@@ -4,7 +4,7 @@ defmodule Pinchflat.MixProject do
|
||||
def project do
|
||||
[
|
||||
app: :pinchflat,
|
||||
version: "2024.5.15",
|
||||
version: "2024.5.16",
|
||||
elixir: "~> 1.16",
|
||||
elixirc_paths: elixirc_paths(Mix.env()),
|
||||
start_permanent: Mix.env() == :prod,
|
||||
|
||||
@@ -13,6 +13,19 @@ defmodule Pinchflat.Boot.PreJobStartupTasksTest do
|
||||
:ok
|
||||
end
|
||||
|
||||
describe "ensure_tmpfile_directory" do
|
||||
test "creates the tmpfile directory if it doesn't exist" do
|
||||
tmpfile_dir = Application.get_env(:pinchflat, :tmpfile_directory)
|
||||
File.rm_rf!(tmpfile_dir)
|
||||
|
||||
refute File.exists?(tmpfile_dir)
|
||||
|
||||
PreJobStartupTasks.init(%{})
|
||||
|
||||
assert File.exists?(tmpfile_dir)
|
||||
end
|
||||
end
|
||||
|
||||
describe "reset_executing_jobs" do
|
||||
test "resets executing jobs" do
|
||||
job = job_fixture()
|
||||
@@ -78,6 +91,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasksTest do
|
||||
|
||||
describe "apply_default_settings" do
|
||||
test "sets yt_dlp version" do
|
||||
File.rm_rf!(Application.get_env(:pinchflat, :tmpfile_directory))
|
||||
Settings.set(yt_dlp_version: nil)
|
||||
|
||||
refute Settings.get!(:yt_dlp_version)
|
||||
@@ -88,6 +102,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasksTest do
|
||||
end
|
||||
|
||||
test "sets apprise version" do
|
||||
File.rm_rf!(Application.get_env(:pinchflat, :tmpfile_directory))
|
||||
Settings.set(apprise_version: nil)
|
||||
|
||||
refute Settings.get!(:apprise_version)
|
||||
|
||||
@@ -7,6 +7,10 @@ defmodule Pinchflat.Utils.CliUtilsTest do
|
||||
test "delegates to System.cmd/3" do
|
||||
assert {"output\n", 0} = CliUtils.wrap_cmd("echo", ["output"])
|
||||
end
|
||||
|
||||
test "sets the current directory to the tmp dir" do
|
||||
assert {"/tmp/test/tmpfiles\n", 0} = CliUtils.wrap_cmd("pwd", [])
|
||||
end
|
||||
end
|
||||
|
||||
describe "parse_options/1" do
|
||||
|
||||
Reference in New Issue
Block a user