From fc4b9856f8cfcb1471e69a261c930b2900a0646e Mon Sep 17 00:00:00 2001 From: Sophie Parker Date: Thu, 31 Dec 2020 09:19:55 +1100 Subject: [PATCH] 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 * Update emoji_cli.rb Remove extraneous comment (macOS-specific comment now with correct line) Co-authored-by: Eugen Rochko --- lib/mastodon/emoji_cli.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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]