mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(apple): don't return Data() to fetchResources (#10605)
When the tunnel first comes up, the first call to `fetchResources` was returning an empty `Data()` instance that the receiver would fail to decode properly because it assumes if a `Data` is non-nil, it is a list of Resources. This resulted in a decode error each time the tunnel was started. Related: https://github.com/firezone/firezone/pull/10603#discussion_r2438472011 --------- Signed-off-by: Jamil <jamilbk@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -297,24 +297,22 @@ class Adapter: @unchecked Sendable {
|
||||
guard let self = self else { return }
|
||||
|
||||
// Convert uniffi resources to FirezoneKit resources and encode with PropertyList
|
||||
let propertyListData: Data
|
||||
if let uniffiResources = self.resources {
|
||||
let firezoneResources = uniffiResources.map { self.convertResource($0) }
|
||||
guard let encoded = try? PropertyListEncoder().encode(firezoneResources) else {
|
||||
Log.log("Failed to encode resources as PropertyList")
|
||||
completionHandler(nil)
|
||||
return
|
||||
}
|
||||
propertyListData = encoded
|
||||
} else {
|
||||
propertyListData = Data()
|
||||
guard let uniffiResources = self.resources
|
||||
else { return completionHandler(nil) }
|
||||
|
||||
let firezoneResources = uniffiResources.map { self.convertResource($0) }
|
||||
|
||||
guard let encoded = try? PropertyListEncoder().encode(firezoneResources)
|
||||
else {
|
||||
Log.log("Failed to encode resources as PropertyList")
|
||||
return completionHandler(nil)
|
||||
}
|
||||
|
||||
if hash == Data(SHA256.hash(data: propertyListData)) {
|
||||
if hash == Data(SHA256.hash(data: encoded)) {
|
||||
// nothing changed
|
||||
completionHandler(nil)
|
||||
} else {
|
||||
completionHandler(propertyListData)
|
||||
completionHandler(encoded)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user