mirror of
https://github.com/ninxsoft/Mist.git
synced 2025-05-30 06:55:24 -04:00
SwiftFormat wrapArguments
This commit is contained in:
parent
09f132ca78
commit
ab68a45ac5
21 changed files with 84 additions and 42 deletions
|
@ -41,7 +41,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
content.sound = .default
|
content.sound = .default
|
||||||
content.categoryIdentifier = success ? UNNotificationCategory.Identifier.success : UNNotificationCategory.Identifier.failure
|
content.categoryIdentifier = success ? UNNotificationCategory.Identifier.success : UNNotificationCategory.Identifier.failure
|
||||||
|
|
||||||
if success,
|
if
|
||||||
|
success,
|
||||||
let url: URL = url {
|
let url: URL = url {
|
||||||
content.userInfo = ["URL": url.path]
|
content.userInfo = ["URL": url.path]
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
extension Dictionary where Key == String {
|
extension Dictionary where Key == String {
|
||||||
func firmwareCSVString() -> String {
|
func firmwareCSVString() -> String {
|
||||||
guard let signed: Bool = self["signed"] as? Bool,
|
guard
|
||||||
|
let signed: Bool = self["signed"] as? Bool,
|
||||||
let name: String = self["name"] as? String,
|
let name: String = self["name"] as? String,
|
||||||
let version: String = self["version"] as? String,
|
let version: String = self["version"] as? String,
|
||||||
let build: String = self["build"] as? String,
|
let build: String = self["build"] as? String,
|
||||||
|
@ -22,7 +23,8 @@ extension Dictionary where Key == String {
|
||||||
}
|
}
|
||||||
|
|
||||||
func installerCSVString() -> String {
|
func installerCSVString() -> String {
|
||||||
guard let identifier: String = self["identifier"] as? String,
|
guard
|
||||||
|
let identifier: String = self["identifier"] as? String,
|
||||||
let name: String = self["name"] as? String,
|
let name: String = self["name"] as? String,
|
||||||
let version: String = self["version"] as? String,
|
let version: String = self["version"] as? String,
|
||||||
let build: String = self["build"] as? String,
|
let build: String = self["build"] as? String,
|
||||||
|
|
|
@ -17,7 +17,8 @@ extension FileManager {
|
||||||
.totalFileAllocatedSizeKey
|
.totalFileAllocatedSizeKey
|
||||||
]
|
]
|
||||||
|
|
||||||
guard let enumerator: FileManager.DirectoryEnumerator = enumerator(at: url, includingPropertiesForKeys: Array(urlResourceKeys), options: [], errorHandler: { _, error -> Bool in
|
guard
|
||||||
|
let enumerator: FileManager.DirectoryEnumerator = enumerator(at: url, includingPropertiesForKeys: Array(urlResourceKeys), options: [], errorHandler: { _, error -> Bool in
|
||||||
enumeratorError = error
|
enumeratorError = error
|
||||||
return false
|
return false
|
||||||
}) else {
|
}) else {
|
||||||
|
|
|
@ -18,7 +18,8 @@ extension URL {
|
||||||
|
|
||||||
let resourceValues: URLResourceValues = try resourceValues(forKeys: urlResourceKeys)
|
let resourceValues: URLResourceValues = try resourceValues(forKeys: urlResourceKeys)
|
||||||
|
|
||||||
guard let isRegularFile: Bool = resourceValues.isRegularFile,
|
guard
|
||||||
|
let isRegularFile: Bool = resourceValues.isRegularFile,
|
||||||
isRegularFile else {
|
isRegularFile else {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -38,7 +39,8 @@ extension URL {
|
||||||
|
|
||||||
var shasum: Insecure.SHA1 = .init()
|
var shasum: Insecure.SHA1 = .init()
|
||||||
|
|
||||||
while try autoreleasepool(invoking: {
|
while
|
||||||
|
try autoreleasepool(invoking: {
|
||||||
try Task.checkCancellation()
|
try Task.checkCancellation()
|
||||||
let data: Data = fileHandle.readData(ofLength: length)
|
let data: Data = fileHandle.readData(ofLength: length)
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,8 @@ class TaskManager: ObservableObject {
|
||||||
} else {
|
} else {
|
||||||
let attributes: [FileAttributeKey: Any] = try FileManager.default.attributesOfItem(atPath: cacheDirectoryURL.path)
|
let attributes: [FileAttributeKey: Any] = try FileManager.default.attributesOfItem(atPath: cacheDirectoryURL.path)
|
||||||
|
|
||||||
guard let posixPermissions: NSNumber = attributes[.posixPermissions] as? NSNumber,
|
guard
|
||||||
|
let posixPermissions: NSNumber = attributes[.posixPermissions] as? NSNumber,
|
||||||
let ownerAccountName: String = attributes[.ownerAccountName] as? String,
|
let ownerAccountName: String = attributes[.ownerAccountName] as? String,
|
||||||
let groupOwnerAccountName: String = attributes[.groupOwnerAccountName] as? String else {
|
let groupOwnerAccountName: String = attributes[.groupOwnerAccountName] as? String else {
|
||||||
throw MistError.missingFileAttributes
|
throw MistError.missingFileAttributes
|
||||||
|
@ -324,7 +325,8 @@ class TaskManager: ObservableObject {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
if installer.sierraOrOlder,
|
if
|
||||||
|
installer.sierraOrOlder,
|
||||||
let package: Package = installer.packages.first {
|
let package: Package = installer.packages.first {
|
||||||
let legacyDiskImageURL: URL = .init(fileURLWithPath: "\(cacheDirectory)/\(installer.id)/\(package.filename)")
|
let legacyDiskImageURL: URL = .init(fileURLWithPath: "\(cacheDirectory)/\(installer.id)/\(package.filename)")
|
||||||
let legacyDiskImageMountPointURL: URL = .init(fileURLWithPath: "/Volumes/Install \(installer.name)")
|
let legacyDiskImageMountPointURL: URL = .init(fileURLWithPath: "/Volumes/Install \(installer.name)")
|
||||||
|
|
|
@ -49,7 +49,8 @@ enum Validator {
|
||||||
throw MistError.invalidFileSize(invalid: fileSize, valid: UInt64(package.size))
|
throw MistError.invalidFileSize(invalid: fileSize, valid: UInt64(package.size))
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let string: String = package.integrityDataURL,
|
guard
|
||||||
|
let string: String = package.integrityDataURL,
|
||||||
let url: URL = URL(string: string),
|
let url: URL = URL(string: string),
|
||||||
let size: Int = package.integrityDataSize else {
|
let size: Int = package.integrityDataSize else {
|
||||||
return
|
return
|
||||||
|
|
|
@ -117,7 +117,8 @@ struct Firmware: Decodable, Hashable, Identifiable {
|
||||||
///
|
///
|
||||||
/// - Returns: An array of Firmware build strings.
|
/// - Returns: An array of Firmware build strings.
|
||||||
static func supportedBuilds() throws -> [String] {
|
static func supportedBuilds() throws -> [String] {
|
||||||
guard let architecture: Architecture = Hardware.architecture,
|
guard
|
||||||
|
let architecture: Architecture = Hardware.architecture,
|
||||||
architecture == .appleSilicon,
|
architecture == .appleSilicon,
|
||||||
let modelIdentifier: String = Hardware.modelIdentifier,
|
let modelIdentifier: String = Hardware.modelIdentifier,
|
||||||
let url: URL = URL(string: Firmware.deviceURLTemplate.replacingOccurrences(of: "MODELIDENTIFIER", with: modelIdentifier)) else {
|
let url: URL = URL(string: Firmware.deviceURLTemplate.replacingOccurrences(of: "MODELIDENTIFIER", with: modelIdentifier)) else {
|
||||||
|
@ -126,7 +127,8 @@ struct Firmware: Decodable, Hashable, Identifiable {
|
||||||
|
|
||||||
let string: String = try String(contentsOf: url)
|
let string: String = try String(contentsOf: url)
|
||||||
|
|
||||||
guard let data: Data = string.data(using: .utf8),
|
guard
|
||||||
|
let data: Data = string.data(using: .utf8),
|
||||||
let dictionary: [String: Any] = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any],
|
let dictionary: [String: Any] = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any],
|
||||||
let array: [[String: Any]] = dictionary["firmwares"] as? [[String: Any]] else {
|
let array: [[String: Any]] = dictionary["firmwares"] as? [[String: Any]] else {
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -57,14 +57,16 @@ enum Hardware {
|
||||||
|
|
||||||
var properties: Unmanaged<CFMutableDictionary>?
|
var properties: Unmanaged<CFMutableDictionary>?
|
||||||
|
|
||||||
guard IORegistryEntryCreateCFProperties(entry, &properties, kCFAllocatorDefault, 0) == KERN_SUCCESS,
|
guard
|
||||||
|
IORegistryEntryCreateCFProperties(entry, &properties, kCFAllocatorDefault, 0) == KERN_SUCCESS,
|
||||||
let properties: Unmanaged<CFMutableDictionary> = properties else {
|
let properties: Unmanaged<CFMutableDictionary> = properties else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let nsDictionary: NSDictionary = properties.takeRetainedValue() as NSDictionary
|
let nsDictionary: NSDictionary = properties.takeRetainedValue() as NSDictionary
|
||||||
|
|
||||||
guard let dictionary: [String: Any] = nsDictionary as? [String: Any],
|
guard
|
||||||
|
let dictionary: [String: Any] = nsDictionary as? [String: Any],
|
||||||
dictionary.keys.contains(key),
|
dictionary.keys.contains(key),
|
||||||
let data: Data = IORegistryEntryCreateCFProperty(entry, key as CFString, kCFAllocatorDefault, 0).takeRetainedValue() as? Data,
|
let data: Data = IORegistryEntryCreateCFProperty(entry, key as CFString, kCFAllocatorDefault, 0).takeRetainedValue() as? Data,
|
||||||
let string: String = String(data: data, encoding: .utf8) else {
|
let string: String = String(data: data, encoding: .utf8) else {
|
||||||
|
|
|
@ -691,7 +691,8 @@ struct Installer: Decodable, Hashable, Identifiable {
|
||||||
|
|
||||||
var compatible: Bool {
|
var compatible: Bool {
|
||||||
// Board ID (Intel)
|
// Board ID (Intel)
|
||||||
if let boardID: String = Hardware.boardID,
|
if
|
||||||
|
let boardID: String = Hardware.boardID,
|
||||||
!boardIDs.isEmpty,
|
!boardIDs.isEmpty,
|
||||||
!boardIDs.contains(boardID) {
|
!boardIDs.contains(boardID) {
|
||||||
return false
|
return false
|
||||||
|
@ -699,7 +700,8 @@ struct Installer: Decodable, Hashable, Identifiable {
|
||||||
|
|
||||||
// Device ID (Apple Silicon or Intel T2)
|
// Device ID (Apple Silicon or Intel T2)
|
||||||
// macOS Big Sur 11 or newer
|
// macOS Big Sur 11 or newer
|
||||||
if version.range(of: "^1[1-9]\\.", options: .regularExpression) != nil,
|
if
|
||||||
|
version.range(of: "^1[1-9]\\.", options: .regularExpression) != nil,
|
||||||
let deviceID: String = Hardware.deviceID,
|
let deviceID: String = Hardware.deviceID,
|
||||||
!deviceIDs.isEmpty,
|
!deviceIDs.isEmpty,
|
||||||
!deviceIDs.contains(deviceID) {
|
!deviceIDs.contains(deviceID) {
|
||||||
|
@ -709,12 +711,14 @@ struct Installer: Decodable, Hashable, Identifiable {
|
||||||
// Model Identifier (Apple Silicon or Intel)
|
// Model Identifier (Apple Silicon or Intel)
|
||||||
// macOS Catalina 10.15 or older
|
// macOS Catalina 10.15 or older
|
||||||
if version.range(of: "^10\\.", options: .regularExpression) != nil {
|
if version.range(of: "^10\\.", options: .regularExpression) != nil {
|
||||||
if let architecture: Architecture = Hardware.architecture,
|
if
|
||||||
|
let architecture: Architecture = Hardware.architecture,
|
||||||
architecture == .appleSilicon {
|
architecture == .appleSilicon {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if let modelIdentifier: String = Hardware.modelIdentifier,
|
if
|
||||||
|
let modelIdentifier: String = Hardware.modelIdentifier,
|
||||||
!unsupportedModelIdentifiers.isEmpty,
|
!unsupportedModelIdentifiers.isEmpty,
|
||||||
unsupportedModelIdentifiers.contains(modelIdentifier) {
|
unsupportedModelIdentifiers.contains(modelIdentifier) {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -46,12 +46,14 @@ enum MistError: Error, Equatable {
|
||||||
case .invalidTerminationStatus(let status, let output, let error):
|
case .invalidTerminationStatus(let status, let output, let error):
|
||||||
var string: String = "Invalid Termination Status: \(status)"
|
var string: String = "Invalid Termination Status: \(status)"
|
||||||
|
|
||||||
if let output: String = output,
|
if
|
||||||
|
let output: String = output,
|
||||||
!output.isEmpty {
|
!output.isEmpty {
|
||||||
string += "\n\n\(output)"
|
string += "\n\n\(output)"
|
||||||
}
|
}
|
||||||
|
|
||||||
if let error: String = error,
|
if
|
||||||
|
let error: String = error,
|
||||||
!error.isEmpty {
|
!error.isEmpty {
|
||||||
string += "\n\n\(error)"
|
string += "\n\n\(error)"
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,8 @@ import UserNotifications
|
||||||
|
|
||||||
class UserNotificationCenterDelegate: NSObject, UNUserNotificationCenterDelegate {
|
class UserNotificationCenterDelegate: NSObject, UNUserNotificationCenterDelegate {
|
||||||
func userNotificationCenter(_: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
|
func userNotificationCenter(_: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
|
||||||
guard response.actionIdentifier == UNNotificationAction.Identifier.show,
|
guard
|
||||||
|
response.actionIdentifier == UNNotificationAction.Identifier.show,
|
||||||
let string: String = response.notification.request.content.userInfo["URL"] as? String else {
|
let string: String = response.notification.request.content.userInfo["URL"] as? String else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,8 @@ struct ActivityView: View {
|
||||||
ForEach(taskGroup.tasks.indices, id: \.self) { index in
|
ForEach(taskGroup.tasks.indices, id: \.self) { index in
|
||||||
VStack {
|
VStack {
|
||||||
ActivityRowView(state: taskGroup.tasks[index].state, description: taskGroup.tasks[index].currentDescription, degrees: degrees)
|
ActivityRowView(state: taskGroup.tasks[index].state, description: taskGroup.tasks[index].currentDescription, degrees: degrees)
|
||||||
if taskGroup.tasks[index].type == .download, taskGroup.tasks[index].state != .pending,
|
if
|
||||||
|
taskGroup.tasks[index].type == .download, taskGroup.tasks[index].state != .pending,
|
||||||
let size: UInt64 = taskGroup.tasks[index].downloadSize {
|
let size: UInt64 = taskGroup.tasks[index].downloadSize {
|
||||||
ActivityProgressView(state: taskGroup.tasks[index].state, value: value, size: size)
|
ActivityProgressView(state: taskGroup.tasks[index].state, value: value, size: size)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ struct FooterView: View {
|
||||||
|
|
||||||
let response: NSApplication.ModalResponse = savePanel.runModal()
|
let response: NSApplication.ModalResponse = savePanel.runModal()
|
||||||
|
|
||||||
guard response == .OK,
|
guard
|
||||||
|
response == .OK,
|
||||||
let url: URL = savePanel.url else {
|
let url: URL = savePanel.url else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,8 @@ struct InstallerVolumeSelectionView: View {
|
||||||
do {
|
do {
|
||||||
let resourceValues: URLResourceValues = try url.resourceValues(forKeys: Set(keys))
|
let resourceValues: URLResourceValues = try url.resourceValues(forKeys: Set(keys))
|
||||||
|
|
||||||
guard let volumeName: String = resourceValues.volumeName,
|
guard
|
||||||
|
let volumeName: String = resourceValues.volumeName,
|
||||||
let volumeLocalizedFormatDescription: String = resourceValues.volumeLocalizedFormatDescription,
|
let volumeLocalizedFormatDescription: String = resourceValues.volumeLocalizedFormatDescription,
|
||||||
let volumeIsReadOnly: Bool = resourceValues.volumeIsReadOnly,
|
let volumeIsReadOnly: Bool = resourceValues.volumeIsReadOnly,
|
||||||
let volumeTotalCapacity: Int = resourceValues.volumeTotalCapacity,
|
let volumeTotalCapacity: Int = resourceValues.volumeTotalCapacity,
|
||||||
|
|
|
@ -91,7 +91,8 @@ struct ListRowInstaller: View {
|
||||||
}
|
}
|
||||||
.help("Download and export macOS Installer")
|
.help("Download and export macOS Installer")
|
||||||
.buttonStyle(.mistAction)
|
.buttonStyle(.mistAction)
|
||||||
if let architecture: Architecture = Hardware.architecture,
|
if
|
||||||
|
let architecture: Architecture = Hardware.architecture,
|
||||||
(architecture == .appleSilicon && installer.bigSurOrNewer) || (architecture == .intel && installer.mavericksOrNewer) {
|
(architecture == .appleSilicon && installer.bigSurOrNewer) || (architecture == .intel && installer.mavericksOrNewer) {
|
||||||
Button {
|
Button {
|
||||||
pressButton(.volumeSelection)
|
pressButton(.volumeSelection)
|
||||||
|
@ -259,7 +260,8 @@ struct ListRowInstaller: View {
|
||||||
|
|
||||||
let filePermissions: FilePermissions = .init(rawValue: CModeT(posixPermissions.int16Value))
|
let filePermissions: FilePermissions = .init(rawValue: CModeT(posixPermissions.int16Value))
|
||||||
|
|
||||||
guard filePermissions == [.ownerReadWriteExecute, .groupReadExecute, .otherReadExecute],
|
guard
|
||||||
|
filePermissions == [.ownerReadWriteExecute, .groupReadExecute, .otherReadExecute],
|
||||||
let ownerAccountName: String = attributes[.ownerAccountName] as? String,
|
let ownerAccountName: String = attributes[.ownerAccountName] as? String,
|
||||||
ownerAccountName == NSUserName(),
|
ownerAccountName == NSUserName(),
|
||||||
let groupOwnerAccountName: String = attributes[.groupOwnerAccountName] as? String,
|
let groupOwnerAccountName: String = attributes[.groupOwnerAccountName] as? String,
|
||||||
|
|
|
@ -70,7 +70,8 @@ struct RefreshView: View {
|
||||||
successful = false
|
successful = false
|
||||||
try? await Task.sleep(nanoseconds: nanoseconds)
|
try? await Task.sleep(nanoseconds: nanoseconds)
|
||||||
|
|
||||||
if let error = error as? MistError,
|
if
|
||||||
|
let error = error as? MistError,
|
||||||
error == .missingDevicesKey {
|
error == .missingDevicesKey {
|
||||||
withAnimation {
|
withAnimation {
|
||||||
firmwaresState = .warning
|
firmwaresState = .warning
|
||||||
|
@ -107,7 +108,8 @@ struct RefreshView: View {
|
||||||
|
|
||||||
let string: String = try String(contentsOf: firmwaresURL, encoding: .utf8)
|
let string: String = try String(contentsOf: firmwaresURL, encoding: .utf8)
|
||||||
|
|
||||||
guard let data: Data = string.data(using: .utf8),
|
guard
|
||||||
|
let data: Data = string.data(using: .utf8),
|
||||||
let dictionary: [String: Any] = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] else {
|
let dictionary: [String: Any] = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] else {
|
||||||
throw MistError.invalidData
|
throw MistError.invalidData
|
||||||
}
|
}
|
||||||
|
@ -119,14 +121,16 @@ struct RefreshView: View {
|
||||||
let supportedBuilds: [String] = try Firmware.supportedBuilds()
|
let supportedBuilds: [String] = try Firmware.supportedBuilds()
|
||||||
|
|
||||||
for (identifier, device) in devices {
|
for (identifier, device) in devices {
|
||||||
guard identifier.contains("Mac"),
|
guard
|
||||||
|
identifier.contains("Mac"),
|
||||||
let device: [String: Any] = device as? [String: Any],
|
let device: [String: Any] = device as? [String: Any],
|
||||||
let firmwaresArray: [[String: Any]] = device["firmwares"] as? [[String: Any]] else {
|
let firmwaresArray: [[String: Any]] = device["firmwares"] as? [[String: Any]] else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for var firmwareDictionary in firmwaresArray {
|
for var firmwareDictionary in firmwaresArray {
|
||||||
if let url: String = firmwareDictionary["url"] as? String,
|
if
|
||||||
|
let url: String = firmwareDictionary["url"] as? String,
|
||||||
url.contains("http://updates-http.cdn-apple.com") {
|
url.contains("http://updates-http.cdn-apple.com") {
|
||||||
firmwareDictionary["url"] = url.replacingOccurrences(of: "http://updates-http.cdn-apple.com", with: "https://updates.cdn-apple.com")
|
firmwareDictionary["url"] = url.replacingOccurrences(of: "http://updates-http.cdn-apple.com", with: "https://updates.cdn-apple.com")
|
||||||
}
|
}
|
||||||
|
@ -167,7 +171,8 @@ struct RefreshView: View {
|
||||||
|
|
||||||
var format: PropertyListSerialization.PropertyListFormat = .xml
|
var format: PropertyListSerialization.PropertyListFormat = .xml
|
||||||
|
|
||||||
guard let catalog: [String: Any] = try PropertyListSerialization.propertyList(from: data, options: [.mutableContainers], format: &format) as? [String: Any],
|
guard
|
||||||
|
let catalog: [String: Any] = try PropertyListSerialization.propertyList(from: data, options: [.mutableContainers], format: &format) as? [String: Any],
|
||||||
let productsDictionary: [String: Any] = catalog["Products"] as? [String: Any] else {
|
let productsDictionary: [String: Any] = catalog["Products"] as? [String: Any] else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -240,7 +245,8 @@ struct RefreshView: View {
|
||||||
dateFormatter.dateFormat = "yyyy-MM-dd"
|
dateFormatter.dateFormat = "yyyy-MM-dd"
|
||||||
|
|
||||||
for (key, value) in dictionary {
|
for (key, value) in dictionary {
|
||||||
guard var value: [String: Any] = value as? [String: Any],
|
guard
|
||||||
|
var value: [String: Any] = value as? [String: Any],
|
||||||
let date: Date = value["PostDate"] as? Date,
|
let date: Date = value["PostDate"] as? Date,
|
||||||
let extendedMetaInfo: [String: Any] = value["ExtendedMetaInfo"] as? [String: Any],
|
let extendedMetaInfo: [String: Any] = value["ExtendedMetaInfo"] as? [String: Any],
|
||||||
extendedMetaInfo["InstallAssistantPackageIdentifiers"] as? [String: Any] != nil,
|
extendedMetaInfo["InstallAssistantPackageIdentifiers"] as? [String: Any] != nil,
|
||||||
|
@ -253,7 +259,8 @@ struct RefreshView: View {
|
||||||
do {
|
do {
|
||||||
let string: String = try String(contentsOf: url, encoding: .utf8)
|
let string: String = try String(contentsOf: url, encoding: .utf8)
|
||||||
|
|
||||||
guard let name: String = nameFromDistribution(string),
|
guard
|
||||||
|
let name: String = nameFromDistribution(string),
|
||||||
let version: String = versionFromDistribution(string),
|
let version: String = versionFromDistribution(string),
|
||||||
let build: String = buildFromDistribution(string),
|
let build: String = buildFromDistribution(string),
|
||||||
!name.isEmpty, !version.isEmpty, !build.isEmpty else {
|
!name.isEmpty, !version.isEmpty, !build.isEmpty else {
|
||||||
|
|
|
@ -57,7 +57,8 @@ struct SettingsDiskImagesView: View {
|
||||||
var items: CFTypeRef?
|
var items: CFTypeRef?
|
||||||
let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &items)
|
let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &items)
|
||||||
|
|
||||||
guard status == noErr,
|
guard
|
||||||
|
status == noErr,
|
||||||
let identities: [SecIdentity] = items as? [SecIdentity] else {
|
let identities: [SecIdentity] = items as? [SecIdentity] else {
|
||||||
self.codesigningIdentities = []
|
self.codesigningIdentities = []
|
||||||
return
|
return
|
||||||
|
@ -67,7 +68,8 @@ struct SettingsDiskImagesView: View {
|
||||||
var certificate: SecCertificate?
|
var certificate: SecCertificate?
|
||||||
let status: OSStatus = SecIdentityCopyCertificate(identity, &certificate)
|
let status: OSStatus = SecIdentityCopyCertificate(identity, &certificate)
|
||||||
|
|
||||||
guard status == noErr,
|
guard
|
||||||
|
status == noErr,
|
||||||
let certificate: SecCertificate = certificate,
|
let certificate: SecCertificate = certificate,
|
||||||
let subject: String = SecCertificateCopySubjectSummary(certificate) as? String,
|
let subject: String = SecCertificateCopySubjectSummary(certificate) as? String,
|
||||||
subject.hasPrefix("Developer ID Application") else {
|
subject.hasPrefix("Developer ID Application") else {
|
||||||
|
|
|
@ -19,7 +19,8 @@ struct SettingsGeneralHelperView: View {
|
||||||
@State private var error: Error?
|
@State private var error: Error?
|
||||||
private let length: CGFloat = 16
|
private let length: CGFloat = 16
|
||||||
private var status: String {
|
private var status: String {
|
||||||
guard installed,
|
guard
|
||||||
|
installed,
|
||||||
let installed: HelperToolInfoPropertyList = installedInfoPropertyList else {
|
let installed: HelperToolInfoPropertyList = installedInfoPropertyList else {
|
||||||
return "Not Installed"
|
return "Not Installed"
|
||||||
}
|
}
|
||||||
|
@ -80,7 +81,8 @@ struct SettingsGeneralHelperView: View {
|
||||||
processing = false
|
processing = false
|
||||||
self.error = error
|
self.error = error
|
||||||
|
|
||||||
if let error: AuthorizationError = error as? AuthorizationError,
|
if
|
||||||
|
let error: AuthorizationError = error as? AuthorizationError,
|
||||||
error == .canceled {
|
error == .canceled {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,8 @@ struct SettingsInstallersCacheView: View {
|
||||||
|
|
||||||
let response: NSApplication.ModalResponse = openPanel.runModal()
|
let response: NSApplication.ModalResponse = openPanel.runModal()
|
||||||
|
|
||||||
guard response == .OK,
|
guard
|
||||||
|
response == .OK,
|
||||||
let url: URL = openPanel.url else {
|
let url: URL = openPanel.url else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,8 @@ struct SettingsInstallersCacheView: View {
|
||||||
for id in ids {
|
for id in ids {
|
||||||
let url: URL = url.appendingPathComponent(id)
|
let url: URL = url.appendingPathComponent(id)
|
||||||
|
|
||||||
guard FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory),
|
guard
|
||||||
|
FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory),
|
||||||
isDirectory.boolValue,
|
isDirectory.boolValue,
|
||||||
let installer: Installer = installer(for: url) else {
|
let installer: Installer = installer(for: url) else {
|
||||||
continue
|
continue
|
||||||
|
@ -151,7 +153,8 @@ struct SettingsInstallersCacheView: View {
|
||||||
let distributionURL: URL = url.appendingPathComponent("\(id).English.dist")
|
let distributionURL: URL = url.appendingPathComponent("\(id).English.dist")
|
||||||
let string: String = try String(contentsOf: distributionURL)
|
let string: String = try String(contentsOf: distributionURL)
|
||||||
|
|
||||||
if let version: String = versionFromDistribution(string),
|
if
|
||||||
|
let version: String = versionFromDistribution(string),
|
||||||
let build: String = buildFromDistribution(string) {
|
let build: String = buildFromDistribution(string) {
|
||||||
let size: UInt64 = try FileManager.default.sizeOfDirectory(at: url)
|
let size: UInt64 = try FileManager.default.sizeOfDirectory(at: url)
|
||||||
return Installer(
|
return Installer(
|
||||||
|
|
|
@ -70,7 +70,8 @@ struct SettingsPackagesView: View {
|
||||||
var items: CFTypeRef?
|
var items: CFTypeRef?
|
||||||
let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &items)
|
let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &items)
|
||||||
|
|
||||||
guard status == noErr,
|
guard
|
||||||
|
status == noErr,
|
||||||
let identities: [SecIdentity] = items as? [SecIdentity] else {
|
let identities: [SecIdentity] = items as? [SecIdentity] else {
|
||||||
self.codesigningIdentities = []
|
self.codesigningIdentities = []
|
||||||
return
|
return
|
||||||
|
@ -80,7 +81,8 @@ struct SettingsPackagesView: View {
|
||||||
var certificate: SecCertificate?
|
var certificate: SecCertificate?
|
||||||
let status: OSStatus = SecIdentityCopyCertificate(identity, &certificate)
|
let status: OSStatus = SecIdentityCopyCertificate(identity, &certificate)
|
||||||
|
|
||||||
guard status == noErr,
|
guard
|
||||||
|
status == noErr,
|
||||||
let certificate: SecCertificate = certificate,
|
let certificate: SecCertificate = certificate,
|
||||||
let subject: String = SecCertificateCopySubjectSummary(certificate) as? String,
|
let subject: String = SecCertificateCopySubjectSummary(certificate) as? String,
|
||||||
subject.hasPrefix("Developer ID Installer") else {
|
subject.hasPrefix("Developer ID Installer") else {
|
||||||
|
|
|
@ -38,7 +38,8 @@ enum HelperToolCommandRunner {
|
||||||
}
|
}
|
||||||
case .fileAttributes:
|
case .fileAttributes:
|
||||||
|
|
||||||
guard let path: String = request.arguments.first,
|
guard
|
||||||
|
let path: String = request.arguments.first,
|
||||||
let ownerAccountName: String = request.arguments.last else {
|
let ownerAccountName: String = request.arguments.last else {
|
||||||
return HelperToolCommandResponse(terminationStatus: 1, standardOutput: nil, standardError: "Invalid attributes: \(request.arguments)")
|
return HelperToolCommandResponse(terminationStatus: 1, standardOutput: nil, standardError: "Invalid attributes: \(request.arguments)")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue