MCPcopy Create free account
hub / github.com/couchbase/moss / persistHeader

Method persistHeader

store.go:390–415  ·  view source on GitHub ↗
(file File)

Source from the content-addressed store, hash-verified

388}
389
390func (s *Store) persistHeader(file File) error {
391 buf, err := json.Marshal(Header{
392 Version: StoreVersion,
393 CreatedAt: time.Now().Format(time.RFC3339),
394 CreatedEndian: endian(),
395 })
396 if err != nil {
397 return err
398 }
399
400 str := "moss-data-store:\n" + string(buf) + "\n"
401 if len(str) >= StorePageSize {
402 return fmt.Errorf("store: header size too big")
403 }
404 str = str + strings.Repeat("\n", StorePageSize-len(str))
405
406 n, err := file.WriteAt([]byte(str), 0)
407 if err != nil {
408 return err
409 }
410 if n != len(str) {
411 return fmt.Errorf("store: could not write full header")
412 }
413
414 return nil
415}
416
417func checkHeader(file File) error {
418 buf := make([]byte, StorePageSize)

Callers 1

startFileLOCKEDMethod · 0.95

Calls 1

endianFunction · 0.70

Tested by

no test coverage detected