fix(PROJ-30): cmd import-piler — Manticore-Backend support
This commit is contained in:
@@ -82,12 +82,28 @@ func runImportPiler(args []string) {
|
|||||||
if backend == "" {
|
if backend == "" {
|
||||||
backend = "xapian"
|
backend = "xapian"
|
||||||
}
|
}
|
||||||
idx, err := index.New(cfg.Index.Path, batchSize, backend)
|
var idxMgr index.TenantIndexer
|
||||||
|
if backend == "manticore" {
|
||||||
|
dsn := cfg.Index.ManticoreDSN
|
||||||
|
if dsn == "" {
|
||||||
|
dsn = "manticore@tcp(127.0.0.1:9306)/"
|
||||||
|
}
|
||||||
|
m, err := index.NewManticoreTenantManager(dsn)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "error: manticore init: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
idxMgr = m
|
||||||
|
} else {
|
||||||
|
m, err := index.NewTenantIndexManager(cfg.Index.Path, batchSize, backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: index init: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: index init: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer idx.Close()
|
idxMgr = m
|
||||||
|
}
|
||||||
|
defer idxMgr.Close()
|
||||||
|
idx := idxMgr
|
||||||
|
|
||||||
// Resolve method
|
// Resolve method
|
||||||
resolvedMethod := *method
|
resolvedMethod := *method
|
||||||
@@ -158,7 +174,7 @@ func runImportPiler(args []string) {
|
|||||||
|
|
||||||
// ── pilerexport method ────────────────────────────────────────────────────
|
// ── pilerexport method ────────────────────────────────────────────────────
|
||||||
|
|
||||||
func runPilerexportMethod(mailStore *storage.Store, idx index.Indexer, binPath, exportDir, dateFrom, dateTo string, dryRun, jsonOut bool) (imported, skipped, errors int) {
|
func runPilerexportMethod(mailStore *storage.Store, idx index.TenantIndexer, binPath, exportDir, dateFrom, dateTo string, dryRun, jsonOut bool) (imported, skipped, errors int) {
|
||||||
bin := resolvePilerexport(binPath)
|
bin := resolvePilerexport(binPath)
|
||||||
if bin == "" {
|
if bin == "" {
|
||||||
fmt.Fprintln(os.Stderr, "error: pilerexport binary not found")
|
fmt.Fprintln(os.Stderr, "error: pilerexport binary not found")
|
||||||
@@ -249,7 +265,7 @@ func runPilerexportMethod(mailStore *storage.Store, idx index.Indexer, binPath,
|
|||||||
|
|
||||||
// ── direct method ─────────────────────────────────────────────────────────
|
// ── direct method ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func runDirectMethod(mailStore *storage.Store, idx index.Indexer, storeDir, keyFilePath string, dryRun, jsonOut bool) (imported, skipped, errors int) {
|
func runDirectMethod(mailStore *storage.Store, idx index.TenantIndexer, storeDir, keyFilePath string, dryRun, jsonOut bool) (imported, skipped, errors int) {
|
||||||
if _, err := os.Stat(storeDir); os.IsNotExist(err) {
|
if _, err := os.Stat(storeDir); os.IsNotExist(err) {
|
||||||
fmt.Fprintf(os.Stderr, "error: store dir not found: %s\n", storeDir)
|
fmt.Fprintf(os.Stderr, "error: store dir not found: %s\n", storeDir)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user