fix(hub): remove stale smart_devices records when a drive is no longer reported (#2178)

* Fix duplicate /dev/sdg-style entries

* only prune devices after complete refreshes

---------

Co-authored-by: henrygd <hank@henrygd.me>
This commit is contained in:
Sven van Ginkel
2026-08-15 19:40:30 +02:00
committed by GitHub
parent 3337dff64b
commit eb5dd230cf
11 changed files with 273 additions and 34 deletions

View File

@@ -70,8 +70,9 @@ type deviceKey struct {
var errNoValidSmartData = fmt.Errorf("no valid SMART data found") // Error for missing data
// Refresh updates SMART data for all known devices
func (sm *SmartManager) Refresh(forceScan bool) error {
// Refresh updates SMART data for all known devices and reports whether every
// discovered device was collected successfully.
func (sm *SmartManager) Refresh(forceScan bool) (bool, error) {
sm.refreshMutex.Lock()
defer sm.refreshMutex.Unlock()
@@ -92,7 +93,7 @@ func (sm *SmartManager) Refresh(forceScan bool) error {
}
}
return sm.resolveRefreshError(scanErr, collectErr)
return scanErr == nil && collectErr == nil, sm.resolveRefreshError(scanErr, collectErr)
}
// devicesSnapshot returns a copy of the current device slice to avoid iterating