X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fmix%2Ftasks%2Fpleroma%2Fuploads.ex;h=c47b7531ef6b59e87a3e69fb080536742b6f88df;hb=bf95dfb240cff8c5a2f8a0930e5309a09ca00ba1;hp=8855b5538e105a3c4a3e3a160e3845813584e1e1;hpb=d7ec0898e5aa7acae463760fd85d1ebf8307b4f9;p=akkoma
diff --git a/lib/mix/tasks/pleroma/uploads.ex b/lib/mix/tasks/pleroma/uploads.ex
index 8855b5538..c47b7531e 100644
--- a/lib/mix/tasks/pleroma/uploads.ex
+++ b/lib/mix/tasks/pleroma/uploads.ex
@@ -1,10 +1,10 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.Uploads do
use Mix.Task
- alias Mix.Tasks.Pleroma.Common
+ import Mix.Pleroma
alias Pleroma.Upload
alias Pleroma.Uploaders.Local
require Logger
@@ -12,19 +12,11 @@ defmodule Mix.Tasks.Pleroma.Uploads do
@log_every 50
@shortdoc "Migrates uploads from local to remote storage"
- @moduledoc """
- Manages uploads
+ @moduledoc File.read!("docs/administration/CLI_tasks/uploads.md")
- ## Migrate uploads from local to remote storage
- mix pleroma.uploads migrate_local TARGET_UPLOADER [OPTIONS...]
- Options:
- - `--delete` - delete local uploads after migrating them to the target uploader
-
- A list of available uploaders can be seen in config.exs
- """
def run(["migrate_local", target_uploader | args]) do
delete? = Enum.member?(args, "--delete")
- Common.start_pleroma()
+ start_pleroma()
local_path = Pleroma.Config.get!([Local, :uploads])
uploader = Module.concat(Pleroma.Uploaders, target_uploader)
@@ -38,10 +30,10 @@ defmodule Mix.Tasks.Pleroma.Uploads do
Pleroma.Config.put([Upload, :uploader], uploader)
end
- Common.shell_info("Migrating files from local #{local_path} to #{to_string(uploader)}")
+ shell_info("Migrating files from local #{local_path} to #{to_string(uploader)}")
if delete? do
- Common.shell_info(
+ shell_info(
"Attention: uploaded files will be deleted, hope you have backups! (--delete ; cancel with ^C)"
)
@@ -78,7 +70,7 @@ defmodule Mix.Tasks.Pleroma.Uploads do
|> Enum.filter(& &1)
total_count = length(uploads)
- Common.shell_info("Found #{total_count} uploads")
+ shell_info("Found #{total_count} uploads")
uploads
|> Task.async_stream(
@@ -90,7 +82,7 @@ defmodule Mix.Tasks.Pleroma.Uploads do
:ok
error ->
- Common.shell_error("failed to upload #{inspect(upload.path)}: #{inspect(error)}")
+ shell_error("failed to upload #{inspect(upload.path)}: #{inspect(error)}")
end
end,
timeout: 150_000
@@ -99,10 +91,10 @@ defmodule Mix.Tasks.Pleroma.Uploads do
# credo:disable-for-next-line Credo.Check.Warning.UnusedEnumOperation
|> Enum.reduce(0, fn done, count ->
count = count + length(done)
- Common.shell_info("Uploaded #{count}/#{total_count} files")
+ shell_info("Uploaded #{count}/#{total_count} files")
count
end)
- Common.shell_info("Done!")
+ shell_info("Done!")
end
end