1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MediaProxy.Invalidation.Script do
8 @behaviour Pleroma.Web.MediaProxy.Invalidation
12 @impl Pleroma.Web.MediaProxy.Invalidation
13 def purge(urls, %{script_path: script_path} = _options) do
20 path = Path.expand(script_path)
22 Logger.debug("Running cache purge: #{inspect(urls)}, #{path}")
24 case do_purge(path, [args]) do
25 {result, exit_status} when exit_status > 0 ->
26 Logger.error("Error while cache purge: #{inspect(result)}")
27 {:error, inspect(result)}
34 def purge(_, _), do: {:error, "not found script path"}
36 defp do_purge(path, args) do
37 System.cmd(path, args)
39 error -> {inspect(error), 1}