diff --git a/internal/linux/net/linkSensors.go b/internal/linux/net/linkSensors.go index 0844ad03a..e67335295 100644 --- a/internal/linux/net/linkSensors.go +++ b/internal/linux/net/linkSensors.go @@ -228,7 +228,7 @@ func (w *AddressWorker) Events(ctx context.Context) (<-chan sensor.Entity, error return sensorCh, nil } -func (w *AddressWorker) ID() string { +func (w *AddressWorker) PreferencesID() string { return preferencesID } diff --git a/internal/linux/net/networkRates.go b/internal/linux/net/networkRates.go index a9ff659f9..3e00d7c34 100644 --- a/internal/linux/net/networkRates.go +++ b/internal/linux/net/networkRates.go @@ -270,7 +270,7 @@ func (w *netStatsWorker) Sensors(_ context.Context) ([]sensor.Entity, error) { return sensors, nil } -func (w *netStatsWorker) ID() string { +func (w *netStatsWorker) PreferencesID() string { return preferencesID } diff --git a/internal/linux/net/worker.go b/internal/linux/net/worker.go index 5fc369396..ac38e649b 100644 --- a/internal/linux/net/worker.go +++ b/internal/linux/net/worker.go @@ -135,7 +135,7 @@ func (w *ConnectionsWorker) Events(ctx context.Context) (<-chan sensor.Entity, e return sensorCh, nil } -func (w *ConnectionsWorker) ID() string { +func (w *ConnectionsWorker) PreferencesID() string { return preferencesID } diff --git a/internal/preferences/worker.go b/internal/preferences/worker.go index f941ee5ed..d9e2db42e 100644 --- a/internal/preferences/worker.go +++ b/internal/preferences/worker.go @@ -19,7 +19,7 @@ import ( // method and an ID that uniquely identifies the worker (and its preferences // file on disk). type Worker[T any] interface { - ID() string + PreferencesID() string DefaultPreferences() T } @@ -45,7 +45,7 @@ func SaveWorkerPreferences[T any](ctx context.Context, worker string, prefs T) e func LoadWorkerPreferences[T any](ctx context.Context, worker Worker[T]) (T, error) { // Load config from file. If the preferences cannot be loaded for any reason // other than the preferences file does not exist , return an error. - data, err := os.ReadFile(workerPreferencesFile(ctx, worker.ID())) + data, err := os.ReadFile(workerPreferencesFile(ctx, worker.PreferencesID())) if err != nil && !errors.Is(err, os.ErrNotExist) { return *new(T), fmt.Errorf("could not read app preferences file: %w", err) } @@ -54,7 +54,7 @@ func LoadWorkerPreferences[T any](ctx context.Context, worker Worker[T]) (T, err // for the worker. if errors.Is(err, os.ErrNotExist) { // Save the newly created preferences to disk. - if err := SaveWorkerPreferences(ctx, worker.ID(), worker.DefaultPreferences()); err != nil { + if err := SaveWorkerPreferences(ctx, worker.PreferencesID(), worker.DefaultPreferences()); err != nil { return *new(T), fmt.Errorf("could not save default preferences: %w", err) }