mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-31 17:59:49 -04:00
refactor(search): single-source the new-index log message
This commit is contained in:
@@ -46,7 +46,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 {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -127,7 +127,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)
|
||||
|
||||
Reference in New Issue
Block a user