(ctx context.Context, cr contentReader, indexEntries []IndirectObjectEntry, startingLength int64, objectID ID)
| 152 | } |
| 153 | |
| 154 | func appendIndexEntriesForObject(ctx context.Context, cr contentReader, indexEntries []IndirectObjectEntry, startingLength int64, objectID ID) (result []IndirectObjectEntry, totalLength int64, _ error) { |
| 155 | if indexObjectID, ok := objectID.IndexObjectID(); ok { |
| 156 | ndx, err := LoadIndexObject(ctx, cr, indexObjectID) |
| 157 | if err != nil { |
| 158 | return nil, 0, errors.Wrapf(err, "error reading index of %v", objectID) |
| 159 | } |
| 160 | |
| 161 | indexEntries, totalLength = appendIndexEntries(indexEntries, startingLength, ndx...) |
| 162 | |
| 163 | return indexEntries, totalLength, nil |
| 164 | } |
| 165 | |
| 166 | // non-index object - the precise length of the object cannot be determined from content due to compression and padding, |
| 167 | // so we must open the object to read its length. |
| 168 | r, err := Open(ctx, cr, objectID) |
| 169 | if err != nil { |
| 170 | return nil, 0, errors.Wrapf(err, "error opening %v", objectID) |
| 171 | } |
| 172 | defer r.Close() //nolint:errcheck |
| 173 | |
| 174 | indexEntries, totalLength = appendIndexEntries(indexEntries, startingLength, IndirectObjectEntry{ |
| 175 | Start: 0, |
| 176 | Length: r.Length(), |
| 177 | Object: objectID, |
| 178 | }) |
| 179 | |
| 180 | return indexEntries, totalLength, nil |
| 181 | } |
| 182 | |
| 183 | func appendIndexEntries(indexEntries []IndirectObjectEntry, startingLength int64, incoming ...IndirectObjectEntry) (result []IndirectObjectEntry, totalLength int64) { |
| 184 | totalLength = startingLength |
no test coverage detected