ref: remove dead code for non-optional zipFile

This commit is contained in:
relikd
2025-11-28 13:21:33 +01:00
parent 71d1b35aac
commit cde957b01f

View File

@@ -22,6 +22,7 @@ struct AppIcon {
os_log(.debug, log: log, "[icon] using iTunesArtwork.") os_log(.debug, log: log, "[icon] using iTunesArtwork.")
return NSImage(data: data)! return NSImage(data: data)!
} }
// else, fallthrough
} }
// Extract image name from app plist // Extract image name from app plist
@@ -49,6 +50,11 @@ struct AppIcon {
} }
// Fallback to default icon // Fallback to default icon
return defaultIcon()
}
/// Return the bundled default icon `"defaultIcon.png"`
private func defaultIcon() -> NSImage {
let iconURL = Bundle.main.url(forResource: "defaultIcon", withExtension: "png")! let iconURL = Bundle.main.url(forResource: "defaultIcon", withExtension: "png")!
return NSImage(contentsOf: iconURL)! return NSImage(contentsOf: iconURL)!
} }
@@ -98,13 +104,9 @@ extension AppIcon {
var matches: [String] = [] var matches: [String] = []
switch meta.type { switch meta.type {
case .IPA: case .IPA:
guard let zipFile = meta.zipFile else {
// in case unzip in memory is not available, fallback to pattern matching with dynamic suffix
return "Payload/*.app/\(iconList.first!)*"
}
for iconPath in iconList { for iconPath in iconList {
let zipPath = "Payload/*.app/\(iconPath)*" let zipPath = "Payload/*.app/\(iconPath)*"
for zip in zipFile.filesMatching(zipPath) { for zip in meta.zipFile!.filesMatching(zipPath) {
if zip.sizeUncompressed > 0 { if zip.sizeUncompressed > 0 {
matches.append(zip.filepath) matches.append(zip.filepath)
} }