refactor(search): single-source the new-index log message

This commit is contained in:
Dominik Schmidt committed 2026-08-18 18:11:41 +02:00
1 parent b14dc31545
commit 6022e8fcfd
3 files changed
+9 -2

No files matched your search

+1 -1
View File
@@ -45,7 +45,7 @@ func NewIndex(root string, logger log.Logger) (bleve.Index, searchmapping.Classi
return nil, searchmapping.Classification{}, err
}
logger.Info().Str("index", destination).Msg("created a new empty search index; if this OpenCloud instance already held files, they are not in it yet, index them by running: opencloud search index --all-spaces --force-rescan")
searchmapping.LogNewIndexCreated(logger, destination)
return index, searchmapping.Classification{Verdict: searchmapping.VerdictEqual}, nil
}
if err != nil {
+7
View File
@@ -43,3 +43,10 @@ func Reconcile(index string, r SchemaReconciler, logger log.Logger) (Classificat
return classification, nil
}
// LogNewIndexCreated logs that a fresh, empty index was created and how to
// backfill it. Both backends call it after creating their index (that path does
// not run through Reconcile); an existing, up-to-date index stays silent.
func LogNewIndexCreated(logger log.Logger, index string) {
logger.Info().Str("index", index).Msg("created a new empty search index; if this OpenCloud instance already held files, they are not in it yet, index them by running: opencloud search index --all-spaces --force-rescan")
}
+1 -1
View File
@@ -128,7 +128,7 @@ func (m IndexManager) Apply(ctx context.Context, name string, client *opensearch
var structErr *opensearchgo.StructError
switch {
case createErr == nil && createResp.Acknowledged:
logger.Info().Str("index", name).Msg("created a new empty search index; if this OpenCloud instance already held files, they are not in it yet, index them by running: opencloud search index --all-spaces --force-rescan")
searchmapping.LogNewIndexCreated(logger, name)
return nil
case createErr == nil:
return fmt.Errorf("failed to create index %s: not acknowledged", name)