about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSophie Parker <dev@cortices.me>2020-12-31 09:19:55 +1100
committerGitHub <noreply@github.com>2020-12-30 23:19:55 +0100
commitc7262d12b22906dbc6340ff23ca4d4ec7056e2f1 (patch)
tree94204b5788748322a8baa336e410c409d7a0dc46
parent4552449c2658db7fab3a7637af18fca9a4a38657 (diff)
Improve Emoji import (fix #15429) (#15430)
* Improve Emoji import

Skip macOS '._' shadow files in tar archive to speed up import

* Fix codeclimate format issue with whitespace

* Update lib/mastodon/emoji_cli.rb

suggestions from Gargron to improve comment

Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>

* Update emoji_cli.rb

Remove extraneous comment (macOS-specific comment now with correct line)

Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
-rw-r--r--lib/mastodon/emoji_cli.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/mastodon/emoji_cli.rb b/lib/mastodon/emoji_cli.rb
index da8fd6a0d..0a1f538e6 100644
--- a/lib/mastodon/emoji_cli.rb
+++ b/lib/mastodon/emoji_cli.rb
@@ -43,7 +43,12 @@ module Mastodon
         tar.each do |entry|
           next unless entry.file? && entry.full_name.end_with?('.png')
 
-          shortcode    = [options[:prefix], File.basename(entry.full_name, '.*'), options[:suffix]].compact.join
+          filename = File.basename(entry.full_name, '.*')
+
+          # Skip macOS shadow files
+          next if filename.start_with?('._')
+
+          shortcode    = [options[:prefix], filename, options[:suffix]].compact.join
           custom_emoji = CustomEmoji.local.find_by(shortcode: shortcode)
 
           if custom_emoji && !options[:overwrite]