| 1 | package control |
| 2 | |
| 3 | import "strings" |
| 4 | |
| 5 | // MaintenanceCommandConflict lets transports preserve the management receipt |
| 6 | // when duplicate compaction is rejected before ordinary input admission. |
| 7 | func MaintenanceCommandConflict(ctrl SessionAPI, input string) (SubmitResult, error) { |
| 8 | if input != "/compact" && !strings.HasPrefix(input, "/compact ") { |
| 9 | return SubmitResult{}, nil |
| 10 | } |
| 11 | reader, ok := ctrl.(RuntimeStateReader) |
| 12 | if !ok { |
| 13 | return SubmitResult{}, nil |
| 14 | } |
| 15 | maintenance := reader.RuntimeStateSnapshot().Maintenance |
| 16 | if maintenance == nil { |
| 17 | return SubmitResult{}, nil |
| 18 | } |
| 19 | err := ErrMaintenanceBusy |
| 20 | if maintenance.Activity == "recovery_required" { |
| 21 | err = ErrMaintenanceRecovery |
| 22 | } |
| 23 | return SubmitResult{Disposition: SubmitManagementHandled, OperationID: maintenance.OperationID}, err |
| 24 | } |
| 25 |