Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/launchpad/artifacts/apple/zipped_xcarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,18 @@ def _parse_asset_element(self, item: dict[str, Any], parent_path: Path) -> Asset
colorspace = item.get("colorspace")

file_extension = Path(filename).suffix.lower()
if filename and file_extension in {".png", ".jpg", ".jpeg", ".heic", ".heif"}:
potential_path = parent_path / f"{image_id}{file_extension}"
if potential_path.exists():
full_path = potential_path
else:
full_path = None
else:
full_path = None
full_path = None

if filename:
if file_extension in {".png", ".jpg", ".jpeg", ".heic", ".heif"}:
potential_path = parent_path / f"{image_id}{file_extension}"
if potential_path.exists():
full_path = potential_path
elif not file_extension:
# No extension, try .png as default (for some asset catalog entries)
potential_path = parent_path / f"{image_id}.png"
if potential_path.exists():
full_path = potential_path

return AssetCatalogElement(
name=name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def _resize_icon_for_analysis(self, img: Image.Image) -> Image.Image:
)

def _is_alternate_icon_file(self, file_info: FileInfo, alternate_icon_names: set[str]) -> bool:
return (
file_info.file_type.lower() in self.OPTIMIZABLE_FORMATS
and Path(file_info.path).stem in alternate_icon_names
)
# Some asset catalog entries have no extension, so we include "other" in the OPTIMIZABLE_FORMATS
file_type_match = file_info.file_type.lower() in (self.OPTIMIZABLE_FORMATS | {"other"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "other" check doesn't seem ideal, is file_type not showing as PNG for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct. I agree it's not ideal but I think it's ok still because there's the additional check of if stem in alternate_icon_names, which is an array that comes from app_info

return file_type_match and Path(file_info.path).stem in alternate_icon_names
Loading