()
| 132 | } |
| 133 | |
| 134 | func (h *handler) handleAttachmentMigration() error { |
| 135 | action := h.getQuery("action") |
| 136 | if action == "" { |
| 137 | action = string(db.BackgroundProcessActionStart) |
| 138 | } |
| 139 | reset := h.getBoolQuery("reset") |
| 140 | |
| 141 | if action != string(db.BackgroundProcessActionStart) && action != string(db.BackgroundProcessActionStop) { |
| 142 | return base.HTTPErrorf(http.StatusBadRequest, "Unknown parameter for 'action'. Must be start or stop") |
| 143 | } |
| 144 | |
| 145 | if action == string(db.BackgroundProcessActionStart) { |
| 146 | err := h.db.AttachmentMigrationManager.Start(h.ctx(), map[string]interface{}{ |
| 147 | "reset": reset, |
| 148 | }) |
| 149 | if err != nil { |
| 150 | return err |
| 151 | } |
| 152 | status, err := h.db.AttachmentMigrationManager.GetStatus(h.ctx()) |
| 153 | if err != nil { |
| 154 | return err |
| 155 | } |
| 156 | h.writeRawJSON(status) |
| 157 | } else if action == string(db.BackgroundProcessActionStop) { |
| 158 | err := h.db.AttachmentMigrationManager.Stop() |
| 159 | if err != nil { |
| 160 | return err |
| 161 | } |
| 162 | status, err := h.db.AttachmentMigrationManager.GetStatus(h.ctx()) |
| 163 | if err != nil { |
| 164 | return err |
| 165 | } |
| 166 | h.writeRawJSON(status) |
| 167 | } |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | func (h *handler) handleGetAttachmentMigration() error { |
| 172 | status, err := h.db.AttachmentMigrationManager.GetStatus(h.ctx()) |
nothing calls this directly
no test coverage detected