fix(ios): wrong keepAlive usage

pull/6747/head
Andelf 2022-09-15 15:35:00 +08:00 committed by Tienson Qin
parent 6dc5517484
commit 46db8f5608
1 changed files with 4 additions and 2 deletions

View File

@ -228,13 +228,14 @@ public class FileSync: CAPPlugin, SyncDebugDelegate {
call.reject("cannot decode ciphertext with utf8") call.reject("cannot decode ciphertext with utf8")
return return
} }
call.keepAlive = true self.bridge?.saveCall(call)
DispatchQueue.global(qos: .default).async { DispatchQueue.global(qos: .default).async {
if let encrypted = AgeEncryption.encryptWithPassphrase(plaintext, passphrase, armor: true) { if let encrypted = AgeEncryption.encryptWithPassphrase(plaintext, passphrase, armor: true) {
call.resolve(["data": String(data: encrypted, encoding: .utf8) as Any]) call.resolve(["data": String(data: encrypted, encoding: .utf8) as Any])
} else { } else {
call.reject("cannot encrypt with passphrase") call.reject("cannot encrypt with passphrase")
} }
self.bridge?.releaseCall(call)
} }
} }
@ -249,13 +250,14 @@ public class FileSync: CAPPlugin, SyncDebugDelegate {
call.reject("cannot decode ciphertext with utf8") call.reject("cannot decode ciphertext with utf8")
return return
} }
call.keepAlive = true self.bridge?.saveCall(call)
DispatchQueue.global(qos: .default).async { DispatchQueue.global(qos: .default).async {
if let decrypted = AgeEncryption.decryptWithPassphrase(ciphertext, passphrase) { if let decrypted = AgeEncryption.decryptWithPassphrase(ciphertext, passphrase) {
call.resolve(["data": String(data: decrypted, encoding: .utf8) as Any]) call.resolve(["data": String(data: decrypted, encoding: .utf8) as Any])
} else { } else {
call.reject("cannot decrypt with passphrase") call.reject("cannot decrypt with passphrase")
} }
self.bridge?.releaseCall(call)
} }
} }