StripLocation, ReadDescription: Silence noisy errors.
This commit is contained in:
parent
100cfe4db8
commit
3ecc861fa7
4 changed files with 30 additions and 19 deletions
|
|
@ -330,7 +330,13 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
|> Enum.each(&write_and_delete(&1, file, opts[:delete]))
|
|> Enum.each(&write_and_delete(&1, file, opts[:delete]))
|
||||||
|
|
||||||
:ok = File.close(file)
|
:ok = File.close(file)
|
||||||
System.cmd("mix", ["format", path])
|
|
||||||
|
# Ensure `mix format` runs in the same env as the current task and doesn't
|
||||||
|
# emit config-time stderr noise (e.g. dev secret warnings) into `mix test`.
|
||||||
|
System.cmd("mix", ["format", path],
|
||||||
|
env: [{"MIX_ENV", to_string(Mix.env())}],
|
||||||
|
stderr_to_stdout: true
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp config_header, do: "import Config\r\n\r\n"
|
defp config_header, do: "import Config\r\n\r\n"
|
||||||
|
|
|
||||||
|
|
@ -29,22 +29,26 @@ defmodule Pleroma.Upload.Filter.Exiftool.ReadDescription do
|
||||||
do: current_description
|
do: current_description
|
||||||
|
|
||||||
defp read_when_empty(_, file, tag) do
|
defp read_when_empty(_, file, tag) do
|
||||||
try do
|
if File.exists?(file) do
|
||||||
{tag_content, 0} =
|
try do
|
||||||
System.cmd("exiftool", ["-b", "-s3", tag, file],
|
{tag_content, 0} =
|
||||||
stderr_to_stdout: false,
|
System.cmd("exiftool", ["-m", "-b", "-s3", tag, file],
|
||||||
parallelism: true
|
stderr_to_stdout: false,
|
||||||
)
|
parallelism: true
|
||||||
|
)
|
||||||
|
|
||||||
tag_content = String.trim(tag_content)
|
tag_content = String.trim(tag_content)
|
||||||
|
|
||||||
if tag_content != "" and
|
if tag_content != "" and
|
||||||
String.length(tag_content) <=
|
String.length(tag_content) <=
|
||||||
Pleroma.Config.get([:instance, :description_limit]),
|
Pleroma.Config.get([:instance, :description_limit]),
|
||||||
do: tag_content,
|
do: tag_content,
|
||||||
else: nil
|
else: nil
|
||||||
rescue
|
rescue
|
||||||
_ in ErlangError -> nil
|
_ in ErlangError -> nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,12 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocation do
|
||||||
|
|
||||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||||
try do
|
try do
|
||||||
case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", "-png:all=", file],
|
case System.cmd("exiftool", ["-m", "-overwrite_original", "-gps:all=", "-png:all=", file],
|
||||||
|
stderr_to_stdout: true,
|
||||||
parallelism: true
|
parallelism: true
|
||||||
) do
|
) do
|
||||||
{_response, 0} -> {:ok, :filtered}
|
{_response, 0} -> {:ok, :filtered}
|
||||||
{error, 1} -> {:error, error}
|
{error, _} -> {:error, error}
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
e in ErlangError ->
|
e in ErlangError ->
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocationTest do
|
||||||
|
|
||||||
assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
|
assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
|
||||||
|
|
||||||
{exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.#{type}"])
|
{exif_original, 0} = System.cmd("exiftool", ["-m", "test/fixtures/DSCN0010.#{type}"])
|
||||||
{exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.#{type}"])
|
{exif_filtered, 0} = System.cmd("exiftool", ["-m", "test/fixtures/DSCN0010_tmp.#{type}"])
|
||||||
|
|
||||||
assert String.match?(exif_original, ~r/GPS/)
|
assert String.match?(exif_original, ~r/GPS/)
|
||||||
refute String.match?(exif_filtered, ~r/GPS/)
|
refute String.match?(exif_filtered, ~r/GPS/)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue