mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: fixed Disk activity reader that tries to read IO when disk is ejected (#2677)
This commit is contained in:
@@ -286,9 +286,11 @@ internal class ActivityReader: Reader<Disks> {
|
||||
}
|
||||
|
||||
private func driveStats(_ idx: Int, _ d: drive) {
|
||||
guard let props = getIOProperties(d.parent) else {
|
||||
return
|
||||
}
|
||||
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOBSDNameMatching(kIOMasterPortDefault, 0, d.BSDName))
|
||||
if service == 0 { return }
|
||||
IOObjectRelease(service)
|
||||
|
||||
guard let props = getIOProperties(d.parent) else { return }
|
||||
|
||||
if let statistics = props.object(forKey: "Statistics") as? NSDictionary {
|
||||
let readBytes = statistics.object(forKey: "Bytes (Read)") as? Int64 ?? 0
|
||||
|
||||
@@ -134,12 +134,11 @@ internal class Settings: NSStackView, Settings_v, NSTextFieldDelegate {
|
||||
}
|
||||
|
||||
internal func setList(_ list: Disks) {
|
||||
let disks = list.map{ $0.mediaName }
|
||||
DispatchQueue.main.async(execute: {
|
||||
let disks = list.map{ $0.mediaName }
|
||||
if self.button?.itemTitles.count != disks.count {
|
||||
self.button?.removeAllItems()
|
||||
}
|
||||
|
||||
if disks != self.button?.itemTitles {
|
||||
self.button?.addItems(withTitles: disks)
|
||||
self.list = disks
|
||||
|
||||
Reference in New Issue
Block a user