Skip to content

Commit 18db73b

Browse files
Address report decryption failure seemoo-lab#239
1 parent a7f7eae commit 18db73b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

OpenHaystack/OpenHaystack/FindMy/FindMyController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ class FindMyController: ObservableObject {
205205

206206
let accessQueue = DispatchQueue(label: "threadSafeAccess", qos: .userInitiated, attributes: .concurrent, autoreleaseFrequency: .workItem, target: nil)
207207
var decryptedReports = [FindMyLocationReport](repeating: FindMyLocationReport(lat: 0, lng: 0, acc: 0, dP: Date(), t: Date(), c: 0), count: reports.count)
208+
var failedDecryptIndexes = [Int]()
208209
DispatchQueue.concurrentPerform(iterations: reports.count) { (reportIdx) in
209210
let report = reports[reportIdx]
210211
guard let key = keyMap[report.id] else { return }
@@ -215,11 +216,16 @@ class FindMyController: ObservableObject {
215216
decryptedReports[reportIdx] = locationReport
216217
}
217218
} catch {
218-
return
219+
accessQueue.async(flags: .barrier) {
220+
failedDecryptIndexes.append(reportIdx)
221+
}
219222
}
220223
}
221224

222225
accessQueue.sync {
226+
for index in failedDecryptIndexes.sorted(by: { $0 > $1 }) {
227+
decryptedReports.remove(at: index)
228+
}
223229
devices[deviceIdx].decryptedReports = decryptedReports
224230
}
225231
}

0 commit comments

Comments
 (0)