Delete attachments when status is deleted
This commit is contained in:
parent
8b4d81609d
commit
88f0eed0f2
8 changed files with 214 additions and 1 deletions
|
|
@ -5,10 +5,12 @@
|
|||
defmodule Pleroma.Uploaders.Local do
|
||||
@behaviour Pleroma.Uploaders.Uploader
|
||||
|
||||
@impl true
|
||||
def get_file(_) do
|
||||
{:ok, {:static_dir, upload_path()}}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def put_file(upload) do
|
||||
{local_path, file} =
|
||||
case Enum.reverse(Path.split(upload.path)) do
|
||||
|
|
@ -33,4 +35,15 @@ defmodule Pleroma.Uploaders.Local do
|
|||
def upload_path do
|
||||
Pleroma.Config.get!([__MODULE__, :uploads])
|
||||
end
|
||||
|
||||
@impl true
|
||||
def delete_file(path) do
|
||||
upload_path()
|
||||
|> Path.join(path)
|
||||
|> File.rm()
|
||||
|> case do
|
||||
:ok -> :ok
|
||||
{:error, posix_error} -> {:error, to_string(posix_error)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue