package searchsvc

import (
	"context"
	"fmt"

	"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
	"go.uber.org/zap"
)

func (exec *execCtx) executeLocal(ctx context.Context) error {
	ids, err := exec.svc.localStorage.search(ctx, exec)
	if err != nil {
		exec.log.Debug(logs.SearchLocalOperationFailed, zap.String("error", err.Error()))
		return err
	}

	if err := exec.writeIDList(ids); err != nil {
		return fmt.Errorf("%s: %w", logs.SearchCouldNotWriteObjectIdentifiers, err)
	}

	return nil
}