aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/upload/filter/exiftool.ex16
-rw-r--r--test/upload/filter/exiftool_test.exs6
2 files changed, 4 insertions, 18 deletions
diff --git a/lib/pleroma/upload/filter/exiftool.ex b/lib/pleroma/upload/filter/exiftool.ex
index b07a671ac..1fd0cfdaa 100644
--- a/lib/pleroma/upload/filter/exiftool.ex
+++ b/lib/pleroma/upload/filter/exiftool.ex
@@ -14,19 +14,9 @@ defmodule Pleroma.Upload.Filter.Exiftool do
# webp is not compatible with exiftool at this time
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
- def filter(%Pleroma.Upload{name: file, tempfile: path, content_type: "image" <> _}) do
- if Regex.match?(~r/\.(webp)$/i, file) do
- {:ok, :noop}
- else
- strip_exif(path)
- end
- end
-
- def filter(_), do: {:ok, :noop}
-
- defp strip_exif(path) do
+ def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
try do
- case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", path], parallelism: true) do
+ case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", file], parallelism: true) do
{_response, 0} -> {:ok, :filtered}
{error, 1} -> {:error, error}
end
@@ -35,4 +25,6 @@ defmodule Pleroma.Upload.Filter.Exiftool do
{:error, "exiftool command not found"}
end
end
+
+ def filter(_), do: {:ok, :noop}
end
diff --git a/test/upload/filter/exiftool_test.exs b/test/upload/filter/exiftool_test.exs
index 84a3f8b30..d4cd4ba11 100644
--- a/test/upload/filter/exiftool_test.exs
+++ b/test/upload/filter/exiftool_test.exs
@@ -37,12 +37,6 @@ defmodule Pleroma.Upload.Filter.ExiftoolTest do
content_type: "image/webp"
}
- bad_type = %Pleroma.Upload{
- name: "sample.webp",
- content_type: "image/jpeg"
- }
-
assert Filter.Exiftool.filter(upload) == {:ok, :noop}
- assert Filter.Exiftool.filter(bad_type) == {:ok, :noop}
end
end