@@ -22,17 +22,14 @@ import QEMUKitInternal
2222class UTMScriptingGuestFileImpl : NSObject , UTMScriptable {
2323 @objc private( set) var id : Int
2424
25- weak private var parent : UTMScriptingVirtualMachineImpl ?
25+ private var parent : UTMScriptingVirtualMachineImpl
2626
2727 init ( from handle: Int , parent: UTMScriptingVirtualMachineImpl ) {
2828 self . id = handle
2929 self . parent = parent
3030 }
3131
3232 override var objectSpecifier : NSScriptObjectSpecifier ? {
33- guard let parent = parent else {
34- return nil
35- }
3633 guard let parentDescription = parent. classDescription as? NSScriptClassDescription else {
3734 return nil
3835 }
@@ -66,7 +63,7 @@ class UTMScriptingGuestFileImpl: NSObject, UTMScriptable {
6663 let isBase64Encoded = command. evaluatedArguments ? [ " isBase64Encoded " ] as? Bool ?? false
6764 let isClosing = command. evaluatedArguments ? [ " isClosing " ] as? Bool ?? true
6865 withScriptCommand ( command) { [ self ] in
69- guard let guestAgent = await parent? . guestAgent else {
66+ guard let guestAgent = await parent. guestAgent else {
7067 throw UTMScriptingVirtualMachineImpl . ScriptingError. guestAgentNotRunning
7168 }
7269 defer {
@@ -96,7 +93,7 @@ class UTMScriptingGuestFileImpl: NSObject, UTMScriptable {
9693 let file = command. evaluatedArguments ? [ " file " ] as? URL
9794 let isClosing = command. evaluatedArguments ? [ " isClosing " ] as? Bool ?? true
9895 withScriptCommand ( command) { [ self ] in
99- guard let guestAgent = await parent? . guestAgent else {
96+ guard let guestAgent = await parent. guestAgent else {
10097 throw UTMScriptingVirtualMachineImpl . ScriptingError. guestAgentNotRunning
10198 }
10299 defer {
@@ -129,7 +126,7 @@ class UTMScriptingGuestFileImpl: NSObject, UTMScriptable {
129126 let isBase64Encoded = command. evaluatedArguments ? [ " isBase64Encoded " ] as? Bool ?? false
130127 let isClosing = command. evaluatedArguments ? [ " isClosing " ] as? Bool ?? true
131128 withScriptCommand ( command) { [ self ] in
132- guard let guestAgent = await parent? . guestAgent else {
129+ guard let guestAgent = await parent. guestAgent else {
133130 throw UTMScriptingVirtualMachineImpl . ScriptingError. guestAgentNotRunning
134131 }
135132 defer {
@@ -153,7 +150,7 @@ class UTMScriptingGuestFileImpl: NSObject, UTMScriptable {
153150 let file = command. evaluatedArguments ? [ " file " ] as? URL
154151 let isClosing = command. evaluatedArguments ? [ " isClosing " ] as? Bool ?? true
155152 withScriptCommand ( command) { [ self ] in
156- guard let guestAgent = await parent? . guestAgent else {
153+ guard let guestAgent = await parent. guestAgent else {
157154 throw UTMScriptingVirtualMachineImpl . ScriptingError. guestAgentNotRunning
158155 }
159156 defer {
@@ -180,7 +177,7 @@ class UTMScriptingGuestFileImpl: NSObject, UTMScriptable {
180177
181178 @objc func close( _ command: NSScriptCommand ) {
182179 withScriptCommand ( command) { [ self ] in
183- guard let guestAgent = await parent? . guestAgent else {
180+ guard let guestAgent = await parent. guestAgent else {
184181 throw UTMScriptingVirtualMachineImpl . ScriptingError. guestAgentNotRunning
185182 }
186183 try await guestAgent. guestFileClose ( id)
0 commit comments