MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / handleAttachmentMigration

Method handleAttachmentMigration

rest/api.go:134–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132}
133
134func (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
171func (h *handler) handleGetAttachmentMigration() error {
172 status, err := h.db.AttachmentMigrationManager.GetStatus(h.ctx())

Callers

nothing calls this directly

Calls 8

getQueryMethod · 0.95
getBoolQueryMethod · 0.95
ctxMethod · 0.95
writeRawJSONMethod · 0.95
HTTPErrorfFunction · 0.92
StartMethod · 0.65
StopMethod · 0.65
GetStatusMethod · 0.45

Tested by

no test coverage detected