9a5720e8ad
Branch Policy Check / Verify merge target (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
PR RC Release / Build RC Release (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Full namespace migration: update the Go module path and all import statements from git.mokoconsulting.tech to code.mokoconsulting.tech. Also updates all URL references in templates, workflows, configs, tests, and documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
35 lines
959 B
Go
35 lines
959 B
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package elasticsearch
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log"
|
|
)
|
|
|
|
// VersionedIndexName returns the full index name with version suffix.
|
|
func (i *Indexer) VersionedIndexName() string {
|
|
return versionedIndexName(i.indexName, i.version)
|
|
}
|
|
|
|
func versionedIndexName(indexName string, version int) string {
|
|
if version == 0 {
|
|
// Old index name without version
|
|
return indexName
|
|
}
|
|
return fmt.Sprintf("%s.v%d", indexName, version)
|
|
}
|
|
|
|
func (i *Indexer) checkOldIndexes(ctx context.Context) {
|
|
for v := range i.version {
|
|
indexName := versionedIndexName(i.indexName, v)
|
|
exists, err := i.indexExists(ctx, indexName)
|
|
if err == nil && exists {
|
|
log.Warn("Found older elasticsearch index named %q, Gitea will keep the old NOT DELETED. You can delete the old version after the upgrade succeed.", indexName)
|
|
}
|
|
}
|
|
}
|