storage: re-probe smartctl lazily so an install from the Disks tab works without a restart
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
c704e87065
commit
38d4ee09ae
@@ -220,7 +220,14 @@ func New(sudo bool) *Manager {
|
|||||||
return &Manager{sudo: sudo, smartctl: ok, cache: map[string]Smart{}}
|
return &Manager{sudo: sudo, smartctl: ok, cache: map[string]Smart{}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) HasSmartctl() bool { return m.smartctl }
|
// HasSmartctl re-probes when it was missing at startup, so an install from the Disks
|
||||||
|
// tab takes effect without a daemon restart.
|
||||||
|
func (m *Manager) HasSmartctl() bool {
|
||||||
|
if !m.smartctl {
|
||||||
|
_, m.smartctl = lookPath("smartctl")
|
||||||
|
}
|
||||||
|
return m.smartctl
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Manager) run(ctx context.Context, args ...string) ([]byte, int, error) {
|
func (m *Manager) run(ctx context.Context, args ...string) ([]byte, int, error) {
|
||||||
if p, ok := lookPath(args[0]); ok {
|
if p, ok := lookPath(args[0]); ok {
|
||||||
@@ -273,7 +280,7 @@ func (m *Manager) Smart(ctx context.Context, dev string, force bool) Smart {
|
|||||||
s.Error = "unknown device"
|
s.Error = "unknown device"
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
if !m.smartctl {
|
if !m.HasSmartctl() {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
|
|||||||
Reference in New Issue
Block a user