fix(PROJ-30): cmd import-piler — Manticore-Backend support
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user