[Bugfix] Fix yt-dlp illegal write issue that causes failure to fetch source details (#247)

* Bandaid fix for yt-dlp write issue

* Ensured tempfile directory on app boot
This commit is contained in:
Kieran
2024-05-15 17:32:56 -07:00
committed by GitHub
parent a7b0af65e2
commit b1a6a6a81f
4 changed files with 39 additions and 1 deletions
+11 -1
View File
@@ -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