fix(PROJ-30): cmd import-piler — Manticore-Backend support

This commit is contained in:
sysops
2026-04-04 01:38:59 +02:00
parent 44bff147ba
commit ecd5ed361b
+23 -7
View File
@@ -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 err != nil { if backend == "manticore" {
fmt.Fprintf(os.Stderr, "error: index init: %v\n", err) dsn := cfg.Index.ManticoreDSN
os.Exit(1) 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 {
fmt.Fprintf(os.Stderr, "error: index init: %v\n", err)
os.Exit(1)
}
idxMgr = m
} }
defer idx.Close() 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)