mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-19 22:06:54 +03:00
Progress fixes
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import SwiftyMobileDevice
|
||||
import ConcurrencyExtras
|
||||
|
||||
extension LockdownClient {
|
||||
static let installerLabel = "supersign"
|
||||
@@ -101,19 +102,24 @@ public actor IntegratedInstaller {
|
||||
|
||||
private var stage: String?
|
||||
|
||||
private func updateStage(
|
||||
to stage: String,
|
||||
initialProgress: Double? = 0
|
||||
) async throws {
|
||||
await Task.yield()
|
||||
try Task.checkCancellation()
|
||||
updateStageIgnoringCancellation(to: stage, initialProgress: initialProgress)
|
||||
private nonisolated let updateTask = LockIsolated<Task<Void, Never>?>(nil)
|
||||
|
||||
private nonisolated func queueUpdateTask(
|
||||
_ perform: @escaping @Sendable (isolated IntegratedInstaller) async -> Void
|
||||
) {
|
||||
updateTask.withValue { task in
|
||||
task = Task { [prev = task] in
|
||||
await prev?.value
|
||||
await perform(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func updateStage(
|
||||
to stage: String,
|
||||
initialProgress: Double? = 0
|
||||
) throws {
|
||||
) async throws {
|
||||
await Task.yield()
|
||||
try Task.checkCancellation()
|
||||
updateStageIgnoringCancellation(to: stage, initialProgress: initialProgress)
|
||||
}
|
||||
@@ -133,11 +139,6 @@ public actor IntegratedInstaller {
|
||||
updateProgressIgnoringCancellation(to: progress)
|
||||
}
|
||||
|
||||
private func updateProgress(to progress: Double?) throws {
|
||||
try Task.checkCancellation()
|
||||
updateProgressIgnoringCancellation(to: progress)
|
||||
}
|
||||
|
||||
private func updateProgressIgnoringCancellation(to progress: Double?) {
|
||||
guard let stage = stage else {
|
||||
preconditionFailure("Cannot change progress without setting stage at least once")
|
||||
@@ -286,9 +287,9 @@ public actor IntegratedInstaller {
|
||||
self.appInstaller = appInstaller
|
||||
try await appInstaller.install(
|
||||
progress: { stage in
|
||||
Task {
|
||||
await self.updateStageIgnoringCancellation(to: stage.displayName)
|
||||
await self.updateProgressIgnoringCancellation(to: stage.displayProgress)
|
||||
self.queueUpdateTask {
|
||||
$0.updateStageIgnoringCancellation(to: stage.displayName)
|
||||
$0.updateProgressIgnoringCancellation(to: stage.displayProgress)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -308,8 +309,8 @@ public actor IntegratedInstaller {
|
||||
let ipa = try await delegate?.compress(
|
||||
payloadDir: appDir.deletingLastPathComponent(),
|
||||
progress: { progress in
|
||||
Task {
|
||||
await self.updateProgressIgnoringCancellation(to: progress)
|
||||
self.queueUpdateTask {
|
||||
$0.updateProgressIgnoringCancellation(to: progress)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -353,13 +354,13 @@ public actor IntegratedInstaller {
|
||||
let bundleID = try await signer.sign(
|
||||
app: appDir,
|
||||
status: { @Sendable status in
|
||||
Task {
|
||||
await self.updateStageIgnoringCancellation(to: status)
|
||||
self.queueUpdateTask {
|
||||
$0.updateStageIgnoringCancellation(to: status)
|
||||
}
|
||||
},
|
||||
progress: { progress in
|
||||
Task {
|
||||
_ = await self.updateProgressIgnoringCancellation(to: progress)
|
||||
self.queueUpdateTask {
|
||||
$0.updateProgressIgnoringCancellation(to: progress)
|
||||
}
|
||||
},
|
||||
didProvision: { @Sendable in
|
||||
@@ -477,8 +478,8 @@ public actor IntegratedInstaller {
|
||||
ipa: app,
|
||||
in: tempDir,
|
||||
progress: { progress in
|
||||
Task {
|
||||
await self.updateProgressIgnoringCancellation(to: progress)
|
||||
self.queueUpdateTask {
|
||||
$0.updateProgressIgnoringCancellation(to: progress)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -99,6 +99,7 @@ public struct Signer {
|
||||
entitlementMapping: entitlements,
|
||||
progress: progress
|
||||
)
|
||||
progress(1)
|
||||
|
||||
return mainInfo.newBundleID
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import Supersign
|
||||
import ConcurrencyExtras
|
||||
|
||||
private func _fetchCode() async -> String? {
|
||||
Console.prompt("Code: ")
|
||||
@@ -22,6 +23,8 @@ actor SupersignCLIDelegate: IntegratedInstallerDelegate, TwoFactorAuthDelegate {
|
||||
self.preferredTeam = preferredTeam
|
||||
}
|
||||
|
||||
private let updateTask = LockIsolated<Task<Void, Never>?>(nil)
|
||||
|
||||
func fetchCode() async -> String? {
|
||||
await _fetchCode()
|
||||
}
|
||||
@@ -100,7 +103,12 @@ actor SupersignCLIDelegate: IntegratedInstallerDelegate, TwoFactorAuthDelegate {
|
||||
}
|
||||
|
||||
nonisolated func installerDidUpdate(toStage stage: String, progress: Double?) {
|
||||
Task { await _installerDidUpdate(toStage: stage, progress: progress) }
|
||||
updateTask.withValue { task in
|
||||
task = Task { [prev = task] in
|
||||
await prev?.value
|
||||
await _installerDidUpdate(toStage: stage, progress: progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static let expiryFormatter: DateFormatter = {
|
||||
|
||||
Reference in New Issue
Block a user