commit: 3ecc861fa7b7c7c1bfc72b7832924425bb4deaf2
parent 100cfe4db83ecb7cfb64ccb2dd37147d5a4c91df
Author: Lain Soykaf <lain@lain.com>
Date: Thu, 8 Jan 2026 13:40:25 +0400
StripLocation, ReadDescription: Silence noisy errors.
Diffstat:
4 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/lib/mix/tasks/pleroma/config.ex b/lib/mix/tasks/pleroma/config.ex
@@ -330,7 +330,13 @@ defmodule Mix.Tasks.Pleroma.Config do
|> Enum.each(&write_and_delete(&1, file, opts[:delete]))
: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
defp config_header, do: "import Config\r\n\r\n"
diff --git a/lib/pleroma/upload/filter/exiftool/read_description.ex b/lib/pleroma/upload/filter/exiftool/read_description.ex
@@ -29,22 +29,26 @@ defmodule Pleroma.Upload.Filter.Exiftool.ReadDescription do
do: current_description
defp read_when_empty(_, file, tag) do
- try do
- {tag_content, 0} =
- System.cmd("exiftool", ["-b", "-s3", tag, file],
- stderr_to_stdout: false,
- parallelism: true
- )
-
- tag_content = String.trim(tag_content)
-
- if tag_content != "" and
- String.length(tag_content) <=
- Pleroma.Config.get([:instance, :description_limit]),
- do: tag_content,
- else: nil
- rescue
- _ in ErlangError -> nil
+ if File.exists?(file) do
+ try do
+ {tag_content, 0} =
+ System.cmd("exiftool", ["-m", "-b", "-s3", tag, file],
+ stderr_to_stdout: false,
+ parallelism: true
+ )
+
+ tag_content = String.trim(tag_content)
+
+ if tag_content != "" and
+ String.length(tag_content) <=
+ Pleroma.Config.get([:instance, :description_limit]),
+ do: tag_content,
+ else: nil
+ rescue
+ _ in ErlangError -> nil
+ end
+ else
+ nil
end
end
end
diff --git a/lib/pleroma/upload/filter/exiftool/strip_location.ex b/lib/pleroma/upload/filter/exiftool/strip_location.ex
@@ -16,11 +16,12 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocation do
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) 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
) do
{_response, 0} -> {:ok, :filtered}
- {error, 1} -> {:error, error}
+ {error, _} -> {:error, error}
end
rescue
e in ErlangError ->
diff --git a/test/pleroma/upload/filter/exiftool/strip_location_test.exs b/test/pleroma/upload/filter/exiftool/strip_location_test.exs
@@ -25,8 +25,8 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocationTest do
assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
- {exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.#{type}"])
- {exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.#{type}"])
+ {exif_original, 0} = System.cmd("exiftool", ["-m", "test/fixtures/DSCN0010.#{type}"])
+ {exif_filtered, 0} = System.cmd("exiftool", ["-m", "test/fixtures/DSCN0010_tmp.#{type}"])
assert String.match?(exif_original, ~r/GPS/)
refute String.match?(exif_filtered, ~r/GPS/)