Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Announce a set-bundle environment update only once it starts

Jackyf9c69800a50e
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
index 4140c802..be47ae10 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift
@@ -792,10 +792,10 @@ struct VPhoneLaunchpadControlCommands {
throw VPhoneLaunchpadError("Stop \(machine.name) before updating its guest environment.")
}
library.actionError = nil
- if updatesEnvironment {
+ // Only once the update starts: a held disk refuses the change first.
+ await library.setBundle(version, for: [machine], updateEnvironment: updatesEnvironment) { machine in
emit("updating the guest environment; console log: \(VPhoneLaunchpadMachineLibrary.consoleLog(machine).path)")
}
- await library.setBundle(version, for: [machine], updateEnvironment: updatesEnvironment)
if let error = takeLibraryError() {
throw error
}
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
index d45e9251..d49ea201 100644
--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift
@@ -350,7 +350,13 @@ final class VPhoneLaunchpadMachineLibrary {
/// until it is updated later. Boot chain and patches stay as created.
/// A machine whose disk another process holds is left as it was rather
/// than rebound without its update (`VPhoneLaunchpadBundleChange`).
- func setBundle(_ version: String, for machines: [Path], updateEnvironment: Bool) async {
+ /// `willUpdate` hears of each update just before it starts.
+ func setBundle(
+ _ version: String,
+ for machines: [Path],
+ updateEnvironment: Bool,
+ willUpdate: (Path) -> Void = { _ in },
+ ) async {
guard bundles.commandLine(version: version) != nil else {
actionError = VPhoneLaunchpadError(String(localized: "VPhone.bundle \(version) is not installed."))
return
@@ -372,7 +378,8 @@ final class VPhoneLaunchpadMachineLibrary {
bind: { try bind(machine, binding) },
// A failed update says first which layer moved.
updateEnvironment: {
- await updateGuestEnvironment(machine) { failure in
+ willUpdate(machine)
+ return await updateGuestEnvironment(machine) { failure in
VPhoneLaunchpadError(
String(localized: "Unable to Update the Guest Environment of \(machine.name)"),
detail: [