Compare commits

...

1 Commits

Author SHA1 Message Date
Alexander Strizhakov
160d4e6af6
fix for doubled path on import 2020-03-20 20:39:59 +03:00
2 changed files with 24 additions and 6 deletions

View File

@ -615,7 +615,7 @@ keeping it in cache for #{div(cache_ms, 1000)}s")
defp files_for_pack(emoji_txt_path, dir_path) do
if File.exists?(emoji_txt_path) do
# There's an emoji.txt file, it's likely from a pack installed by the pack manager.
# Make a pack.json file from the contents of that emoji.txt fileh
# Make a pack.json file from the contents of that emoji.txt file
# FIXME: Copy-pasted from Pleroma.Emoji/load_from_file_stream/2
@ -627,11 +627,23 @@ keeping it in cache for #{div(cache_ms, 1000)}s")
case String.split(line, ~r/,\s*/) do
# This matches both strings with and without tags
# and we don't care about tags here
[name, file | _] -> {name, file}
_ -> nil
[name, file | _] ->
file_dir_name = Path.dirname(file)
file =
if String.ends_with?(dir_path, file_dir_name) do
Path.basename(file)
else
file
end
{name, file}
_ ->
nil
end
end)
|> Enum.filter(fn x -> not is_nil(x) end)
|> Enum.filter(& &1)
|> Enum.into(%{})
else
# If there's no emoji.txt, assume all files

View File

@ -448,7 +448,12 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
File.rm!("#{@emoji_dir_path}/test_pack_for_import/pack.json")
refute File.exists?("#{@emoji_dir_path}/test_pack_for_import/pack.json")
emoji_txt_content = "blank, blank.png, Fun\n\nblank2, blank.png"
emoji_txt_content = """
blank, blank.png, Fun
blank2, blank.png
foo, /emoji/test_pack_for_import/blank.png
bar
"""
File.write!("#{@emoji_dir_path}/test_pack_for_import/emoji.txt", emoji_txt_content)
@ -460,7 +465,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
assert resp["test_pack_for_import"]["files"] == %{
"blank" => "blank.png",
"blank2" => "blank.png"
"blank2" => "blank.png",
"foo" => "blank.png"
}
end
end