Skip to content

Commit

Permalink
fix(web): 修复 Android 上传包含自适应图标获取图标失败
Browse files Browse the repository at this point in the history
  • Loading branch information
icyleaf committed Jan 10, 2020
1 parent 6bd9895 commit 479170b
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions app/models/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,28 @@ def self.upload_file(params, source = 'Web')
create(params) do |release|
unless release.file.blank?
begin
app_info = AppInfo.parse(release.file.path)
parser = AppInfo.parse(release.file.path)
release.source = source
release.bundle_id = app_info.bundle_id
release.release_version = app_info.release_version
release.build_version = app_info.build_version
release.release_type ||= app_info.release_type if app_info.os == AppInfo::Platform::IOS

if icon_file = app_info.icons.last.try(:[], :file)
release.icon = decode_icon(icon_file)
release.bundle_id = parser.bundle_id
release.release_version = parser.release_version
release.build_version = parser.build_version

if parser.os == AppInfo::Platform::IOS
release.release_type ||= parser.release_type

icon_file = parser.icons.last.try(:[], :file)
release.icon = decode_icon(icon_file) if icon_file
else
# 处理 Android anydpi 自适应图标
icon_file = parser.icons.select {|f| File.extname(f[:file]) != '.xml' }.last.try(:[], :file)
release.icon = icon_file
end

if app_info.os == AppInfo::Platform::IOS &&
app_info.release_type == AppInfo::IPA::ExportType::ADHOC &&
(devices = app_info.devices) && !device.blank?
release.devices = devices
# iOS 且是 AdHoc 尝试解析 UDID 列表
if parser.os == AppInfo::Platform::IOS &&
parser.release_type == AppInfo::IPA::ExportType::ADHOC &&
!parser.devices.blank?
release.devices = parser.devices
end
rescue AppInfo::UnkownFileTypeError
release.errors.add(:file, '上传的应用无法正确识别')
Expand Down

0 comments on commit 479170b

Please sign in to comment.