fix: fixed Disk activity reader that tries to read IO when disk is ejected (#2677)

This commit is contained in:
Serhiy Mytrovtsiy
2025-08-29 22:43:49 +02:00
parent 37701ac9da
commit 053f265bdb
2 changed files with 6 additions and 5 deletions

View File

@@ -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

View File

@@ -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