diff options
| -rw-r--r-- | config/config.exs | 3 | ||||
| -rw-r--r-- | docs/configuration/cheatsheet.md | 6 | ||||
| -rw-r--r-- | lib/pleroma/backup.ex | 7 | 
3 files changed, 14 insertions, 2 deletions
diff --git a/config/config.exs b/config/config.exs index 09023e2c3..0e12d6e15 100644 --- a/config/config.exs +++ b/config/config.exs @@ -820,7 +820,8 @@ config :pleroma, Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.PleromaAuthent  config :pleroma, Pleroma.Backup,    purge_after_days: 30, -  limit_days: 7 +  limit_days: 7, +  dir: nil  # Import environment specific config. This must remain at the bottom  # of this file so it overrides the configuration defined above. diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md index 8da8a7bd6..9271964f1 100644 --- a/docs/configuration/cheatsheet.md +++ b/docs/configuration/cheatsheet.md @@ -1090,6 +1090,12 @@ Control favicons for instances.  * `:purge_after_days` an integer, remove backup achives after N days.  * `:limit_days` an integer, limit user to export not more often than once per N days. +* `:dir` a string with a path to backup temporary directory or `nil` to let Pleroma choose temporary directory in the following order: +    1. the directory named by the TMPDIR environment variable +    2. the directory named by the TEMP environment variable +    3. the directory named by the TMP environment variable +    4. C:\TMP on Windows or /tmp on Unix-like operating systems +    5. as a last resort, the current working directory  ## Frontend management diff --git a/lib/pleroma/backup.ex b/lib/pleroma/backup.ex index 3b85dd1c1..450dd5b84 100644 --- a/lib/pleroma/backup.ex +++ b/lib/pleroma/backup.ex @@ -126,7 +126,7 @@ defmodule Pleroma.Backup do    def export(%__MODULE__{} = backup) do      backup = Repo.preload(backup, :user)      name = String.trim_trailing(backup.file_name, ".zip") -    dir = Path.join(System.tmp_dir!(), name) +    dir = dir(name)      with :ok <- File.mkdir(dir),           :ok <- actor(dir, backup.user), @@ -139,6 +139,11 @@ defmodule Pleroma.Backup do      end    end +  def dir(name) do +    dir = Pleroma.Config.get([__MODULE__, :dir]) || System.tmp_dir!() +    Path.join(dir, name) +  end +    def upload(%__MODULE__{} = backup, zip_path) do      uploader = Pleroma.Config.get([Pleroma.Upload, :uploader])  | 
