Move any large revision bodies to external document storage
(ctx context.Context, dataStore base.DataStore)
| 907 | |
| 908 | // Move any large revision bodies to external document storage |
| 909 | func (doc *Document) migrateRevisionBodies(ctx context.Context, dataStore base.DataStore) error { |
| 910 | |
| 911 | for _, revID := range doc.History.GetLeaves() { |
| 912 | revInfo, err := doc.History.getInfo(revID) |
| 913 | if err != nil { |
| 914 | continue |
| 915 | } |
| 916 | if len(revInfo.Body) > MaximumInlineBodySize { |
| 917 | bodyKey := generateRevBodyKey(doc.ID, revID) |
| 918 | persistErr := doc.persistRevisionBody(dataStore, bodyKey, revInfo.Body) |
| 919 | if persistErr != nil { |
| 920 | base.WarnfCtx(ctx, "Unable to store revision body for doc %s, rev %s externally: %v", base.UD(doc.ID), revID, persistErr) |
| 921 | continue |
| 922 | } |
| 923 | revInfo.BodyKey = bodyKey |
| 924 | } |
| 925 | } |
| 926 | return nil |
| 927 | } |
| 928 | |
| 929 | func generateRevBodyKey(docid, revid string) (revBodyKey string) { |
| 930 | return base.RevBodyPrefix + generateRevDigest(docid, revid) |
no test coverage detected