fix(dolt): enable server mode for Gas Town integration (bd-nnjik)
- Skip Bootstrap when ServerMode is true (bootstrap is for embedded cold-start) - Fix doltExists() to follow symlinks using os.Stat - Pass database name from metadata.json to DoltStore config Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
a9c8c952f6
commit
db0c6fbd3f
@@ -15,34 +15,38 @@ import (
|
||||
|
||||
func init() {
|
||||
RegisterBackend(configfile.BackendDolt, func(ctx context.Context, path string, opts Options) (storage.Storage, error) {
|
||||
// Check if bootstrap is needed (JSONL exists but Dolt doesn't)
|
||||
// Path is the dolt subdirectory, parent is .beads directory
|
||||
beadsDir := filepath.Dir(path)
|
||||
// Only bootstrap in embedded mode - server mode has database on server
|
||||
if !opts.ServerMode {
|
||||
// Check if bootstrap is needed (JSONL exists but Dolt doesn't)
|
||||
// Path is the dolt subdirectory, parent is .beads directory
|
||||
beadsDir := filepath.Dir(path)
|
||||
|
||||
bootstrapped, result, err := dolt.Bootstrap(ctx, dolt.BootstrapConfig{
|
||||
BeadsDir: beadsDir,
|
||||
DoltPath: path,
|
||||
LockTimeout: opts.LockTimeout,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bootstrap failed: %w", err)
|
||||
}
|
||||
bootstrapped, result, err := dolt.Bootstrap(ctx, dolt.BootstrapConfig{
|
||||
BeadsDir: beadsDir,
|
||||
DoltPath: path,
|
||||
LockTimeout: opts.LockTimeout,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bootstrap failed: %w", err)
|
||||
}
|
||||
|
||||
if bootstrapped && result != nil {
|
||||
// Report bootstrap results
|
||||
fmt.Fprintf(os.Stderr, "Bootstrapping Dolt from JSONL...\n")
|
||||
if len(result.ParseErrors) > 0 {
|
||||
fmt.Fprintf(os.Stderr, " Skipped %d malformed lines (see above for details)\n", len(result.ParseErrors))
|
||||
if bootstrapped && result != nil {
|
||||
// Report bootstrap results
|
||||
fmt.Fprintf(os.Stderr, "Bootstrapping Dolt from JSONL...\n")
|
||||
if len(result.ParseErrors) > 0 {
|
||||
fmt.Fprintf(os.Stderr, " Skipped %d malformed lines (see above for details)\n", len(result.ParseErrors))
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, " Imported %d issues", result.IssuesImported)
|
||||
if result.IssuesSkipped > 0 {
|
||||
fmt.Fprintf(os.Stderr, ", skipped %d duplicates", result.IssuesSkipped)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "\n Dolt database ready\n")
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, " Imported %d issues", result.IssuesImported)
|
||||
if result.IssuesSkipped > 0 {
|
||||
fmt.Fprintf(os.Stderr, ", skipped %d duplicates", result.IssuesSkipped)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "\n Dolt database ready\n")
|
||||
}
|
||||
|
||||
return dolt.New(ctx, &dolt.Config{
|
||||
Path: path,
|
||||
Database: opts.Database,
|
||||
ReadOnly: opts.ReadOnly,
|
||||
ServerMode: opts.ServerMode,
|
||||
ServerHost: opts.ServerHost,
|
||||
|
||||
Reference in New Issue
Block a user