Merge branch 'emoji-api-errors' into 'develop'
Emoji api error if emoji dir is not writable Closes admin-fe#62 See merge request pleroma/pleroma!2161
This commit is contained in:
commit
e2f2602fdc
|
@ -573,11 +573,14 @@ def update_file(conn, %{"action" => action}) do
|
||||||
assumed to be emojis and stored in the new `pack.json` file.
|
assumed to be emojis and stored in the new `pack.json` file.
|
||||||
"""
|
"""
|
||||||
def import_from_fs(conn, _params) do
|
def import_from_fs(conn, _params) do
|
||||||
with {:ok, results} <- File.ls(emoji_dir_path()) do
|
emoji_path = emoji_dir_path()
|
||||||
|
|
||||||
|
with {:ok, %{access: :read_write}} <- File.stat(emoji_path),
|
||||||
|
{:ok, results} <- File.ls(emoji_path) do
|
||||||
imported_pack_names =
|
imported_pack_names =
|
||||||
results
|
results
|
||||||
|> Enum.filter(fn file ->
|
|> Enum.filter(fn file ->
|
||||||
dir_path = Path.join(emoji_dir_path(), file)
|
dir_path = Path.join(emoji_path, file)
|
||||||
# Find the directories that do NOT have pack.json
|
# Find the directories that do NOT have pack.json
|
||||||
File.dir?(dir_path) and not File.exists?(Path.join(dir_path, "pack.json"))
|
File.dir?(dir_path) and not File.exists?(Path.join(dir_path, "pack.json"))
|
||||||
end)
|
end)
|
||||||
|
@ -585,6 +588,11 @@ def import_from_fs(conn, _params) do
|
||||||
|
|
||||||
json(conn, imported_pack_names)
|
json(conn, imported_pack_names)
|
||||||
else
|
else
|
||||||
|
{:ok, %{access: _}} ->
|
||||||
|
conn
|
||||||
|
|> put_status(:internal_server_error)
|
||||||
|
|> json(%{error: "Error: emoji pack directory must be writable"})
|
||||||
|
|
||||||
{:error, _} ->
|
{:error, _} ->
|
||||||
conn
|
conn
|
||||||
|> put_status(:internal_server_error)
|
|> put_status(:internal_server_error)
|
||||||
|
|
|
@ -6,7 +6,6 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
@emoji_dir_path Path.join(
|
@emoji_dir_path Path.join(
|
||||||
|
|
Loading…
Reference in New Issue