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

Method handleGetCompact

rest/api.go:100–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98}
99
100func (h *handler) handleGetCompact() error {
101 compactionType := h.getQuery("type")
102 if compactionType == "" {
103 compactionType = compactionTypeTombstone
104 }
105
106 if compactionType != compactionTypeTombstone && compactionType != compactionTypeAttachment {
107 return base.HTTPErrorf(http.StatusBadRequest, "Unknown parameter for 'type'. Must be 'tombstone' or 'attachment'")
108 }
109
110 auditFields := base.AuditFields{base.AuditFieldCompactionType: compactionType}
111 var status []byte
112 var err error
113 if compactionType == compactionTypeTombstone {
114 status, err = h.db.TombstoneCompactionManager.GetStatus(h.ctx())
115 if err != nil {
116 return err
117 }
118 base.Audit(h.ctx(), base.AuditIDDatabaseCompactStatus, auditFields)
119 }
120
121 if compactionType == compactionTypeAttachment {
122 status, err = h.db.AttachmentCompactionManager.GetStatus(h.ctx())
123 if err != nil {
124 return err
125 }
126 base.Audit(h.ctx(), base.AuditIDDatabaseCompactStatus, auditFields)
127 }
128
129 h.writeRawJSON(status)
130
131 return nil
132}
133
134func (h *handler) handleAttachmentMigration() error {
135 action := h.getQuery("action")

Callers

nothing calls this directly

Calls 6

getQueryMethod · 0.95
ctxMethod · 0.95
writeRawJSONMethod · 0.95
HTTPErrorfFunction · 0.92
AuditFunction · 0.92
GetStatusMethod · 0.45

Tested by

no test coverage detected