From ecd5ed361bb909b01c5f1dec355378f82d6da549 Mon Sep 17 00:00:00 2001 From: sysops Date: Sat, 4 Apr 2026 01:38:59 +0200 Subject: [PATCH] =?UTF-8?q?fix(PROJ-30):=20cmd=20import-piler=20=E2=80=94?= =?UTF-8?q?=20Manticore-Backend=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/archivmail/cmd_import_piler.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/cmd/archivmail/cmd_import_piler.go b/cmd/archivmail/cmd_import_piler.go index 74d6bdd..336454c 100644 --- a/cmd/archivmail/cmd_import_piler.go +++ b/cmd/archivmail/cmd_import_piler.go @@ -82,12 +82,28 @@ func runImportPiler(args []string) { if backend == "" { backend = "xapian" } - idx, err := index.New(cfg.Index.Path, batchSize, backend) - if err != nil { - fmt.Fprintf(os.Stderr, "error: index init: %v\n", err) - os.Exit(1) + 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 { + 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 resolvedMethod := *method @@ -158,7 +174,7 @@ func runImportPiler(args []string) { // ── 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) if bin == "" { fmt.Fprintln(os.Stderr, "error: pilerexport binary not found") @@ -249,7 +265,7 @@ func runPilerexportMethod(mailStore *storage.Store, idx index.Indexer, binPath, // ── 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) { fmt.Fprintf(os.Stderr, "error: store dir not found: %s\n", storeDir) os.Exit(1)