mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +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) {
|
private func driveStats(_ idx: Int, _ d: drive) {
|
||||||
guard let props = getIOProperties(d.parent) else {
|
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOBSDNameMatching(kIOMasterPortDefault, 0, d.BSDName))
|
||||||
return
|
if service == 0 { return }
|
||||||
}
|
IOObjectRelease(service)
|
||||||
|
|
||||||
|
guard let props = getIOProperties(d.parent) else { return }
|
||||||
|
|
||||||
if let statistics = props.object(forKey: "Statistics") as? NSDictionary {
|
if let statistics = props.object(forKey: "Statistics") as? NSDictionary {
|
||||||
let readBytes = statistics.object(forKey: "Bytes (Read)") as? Int64 ?? 0
|
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) {
|
internal func setList(_ list: Disks) {
|
||||||
let disks = list.map{ $0.mediaName }
|
|
||||||
DispatchQueue.main.async(execute: {
|
DispatchQueue.main.async(execute: {
|
||||||
|
let disks = list.map{ $0.mediaName }
|
||||||
if self.button?.itemTitles.count != disks.count {
|
if self.button?.itemTitles.count != disks.count {
|
||||||
self.button?.removeAllItems()
|
self.button?.removeAllItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
if disks != self.button?.itemTitles {
|
if disks != self.button?.itemTitles {
|
||||||
self.button?.addItems(withTitles: disks)
|
self.button?.addItems(withTitles: disks)
|
||||||
self.list = disks
|
self.list = disks
|
||||||
|
|||||||
Reference in New Issue
Block a user