mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
35 lines
932 B
Go
35 lines
932 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package elasticsearch
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/hanzoai/git/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, Hanzo Git will keep the old NOT DELETED. You can delete the old version after the upgrade succeed.", indexName)
|
|
}
|
|
}
|
|
}
|