Format formats the metadata header as a fixed-width string. The header (without newline) is exactly 99 bytes.
()
| 467 | // Format formats the metadata header as a fixed-width string. |
| 468 | // The header (without newline) is exactly 99 bytes. |
| 469 | func (m IndexMetaData) Format() ([]byte, error) { |
| 470 | headerContent := fmt.Sprintf("VERSION=%d,RECORDCOUNT=%d,RECORDSIZE=%d,CHECKSUM=%d", m.IndexVersion, m.RecordCount, m.RecordSize, m.Checksum) |
| 471 | if len(headerContent) > FixedHeaderTotalLength-1 { |
| 472 | return nil, fmt.Errorf("header content too long: %d bytes", len(headerContent)) |
| 473 | } |
| 474 | padded := headerContent + strings.Repeat(" ", FixedHeaderTotalLength-1-len(headerContent)) |
| 475 | return []byte(padded + string(IndexLineTerminatorV1)), nil |
| 476 | } |
| 477 | |
| 478 | // writeCompleteIndex writes metadata and all records atomically via temp file + rename. |
| 479 | func (idx *UserIndex) writeCompleteIndex(records []IndexUserRecord) error { |
no outgoing calls
no test coverage detected