mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: prevent disk duplication in the list because of a data race. It causes the popup view or widget to stop updating the value (#1624)
This commit is contained in:
@@ -47,7 +47,7 @@ public struct drive: Codable {
|
||||
}
|
||||
|
||||
public class Disks: Codable {
|
||||
private var queue: DispatchQueue = DispatchQueue(label: "eu.exelban.Stats.Disk.SynchronizedArray", attributes: .concurrent)
|
||||
private var queue: DispatchQueue = DispatchQueue(label: "eu.exelban.Stats.Disk.SynchronizedArray")
|
||||
private var array: [drive] = []
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
@@ -108,7 +108,9 @@ public class Disks: Codable {
|
||||
|
||||
public func append( _ element: drive) {
|
||||
self.queue.async(flags: .barrier) {
|
||||
self.array.append(element)
|
||||
if !self.array.contains(where: {$0.BSDName == element.BSDName}) {
|
||||
self.array.append(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user